/* ==========================================
   CRM STYLESHEET
   Injury Lead Management System
   ========================================== */

/* ==========================================
   CSS VARIABLES
   ========================================== */
:root {
    /* Brand Colors */
    --primary-gradient-start:#ed2024;
    --primary-gradient-end:maroon;
    --primary:#ed2024;
    --primary-dark: maroon;
    
    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Status Colors */
    --status-new-bg: #dbeafe;
    --status-new-text: #1e40af;
    --status-contacted-bg: #fef3c7;
    --status-contacted-text: #92400e;
    --status-qualified-bg: #d1fae5;
    --status-qualified-text: #065f46;
    --status-converted-bg: #dcfce7;
    --status-converted-text: #166534;
    --status-disqualified-bg: #fee2e2;
    --status-disqualified-text: #991b1b;
    --status-lost-bg: #f3f4f6;
    --status-lost-text: #4b5563;
    
    /* Priority Colors */
    --priority-urgent: #dc2626;
    --priority-high: #ea580c;
    --priority-medium: #ca8a04;
    --priority-low: #6b7280;
    
    /* Lead Score Colors */
    --score-high: #16a34a;
    --score-medium: #ca8a04;
    --score-low: #dc2626;
    
    /* Success/Error */
    --success: #10b981;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --error: #ef4444;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
}

/* ==========================================
   RESET & BASE STYLES
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   LOGIN PAGE STYLES
   ========================================== */
.login-body {
    /* background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%); */
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 400px;
    width: 100%;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-size: 24px;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.login-logo p {
    color: var(--gray-600);
    font-size: 14px;
}

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

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

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.login-error {
    background: var(--error-bg);
    color: var(--error-text);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid #fecaca;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    /* background: #ed2024; */
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

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

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--gray-600);
    font-size: 12px;
}

/* ==========================================
   DASHBOARD HEADER
   ========================================== */
.header {
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    /* background: black; */
    color: white;
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info span {
    font-size: 14px;
    opacity: 0.9;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 8px 16px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

/* ==========================================
   CONTAINER & LAYOUT
   ========================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* ==========================================
   FILTERS
   ========================================== */
.filters {
    background: white;
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.filters label {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-700);
}

.filters select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.filters select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-secondary {
    background: var(--gray-50);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
    color: var(--gray-900);
}

.btn-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* Icon-only action buttons — no background, just colored icon */
.btn-icon {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: opacity 0.15s;
    text-decoration: none;
}

.btn-icon:hover {
    opacity: 0.7;
}

.btn-icon-edit {
    color: var(--primary);
}

.btn-icon-delete {
    color: #b91c1c;
}

.btn-icon-configure {
    color: var(--gray-500);
}

.btn-icon .material-icons-outlined {
    font-size: 20px;
}

/* ==========================================
   STATS CARDS
   ========================================== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-number {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--gray-600);
    font-weight: 500;
}

/* ==========================================
   TABLES
   ========================================== */
.leads-table-container {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--gray-50);
}

th {
    padding: 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

tbody tr:hover {
    background: var(--gray-50);
}

/* ==========================================
   BADGES
   ========================================== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-new { background: var(--status-new-bg); color: var(--status-new-text); }
.status-contacted { background: var(--status-contacted-bg); color: var(--status-contacted-text); }
.status-qualified { background: var(--status-qualified-bg); color: var(--status-qualified-text); }
.status-converted { background: var(--status-converted-bg); color: var(--status-converted-text); }
.status-disqualified { background: var(--status-disqualified-bg); color: var(--status-disqualified-text); }
.status-lost { background: var(--status-lost-bg); color: var(--status-lost-text); }

.priority-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.priority-low { background: var(--gray-100); color: var(--gray-600); }
.priority-medium { background: var(--status-contacted-bg); color: var(--status-contacted-text); }
.priority-high { background: #fed7aa; color: #9a3412; }
.priority-urgent { background: #fecaca; color: var(--priority-urgent); }

/* ==========================================
   LEAD SCORE
   ========================================== */
.lead-score {
    font-weight: 700;
    font-size: 16px;
}

.score-high { color: var(--score-high); }
.score-medium { color: var(--score-medium); }
.score-low { color: var(--score-low); }

/* ==========================================
   ACTIONS
   ========================================== */
.actions {
    display: flex;
    gap: 8px;
}

/* ==========================================
   ALERTS
   ========================================== */
.alert {
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid #fecaca;
}

/* ==========================================
   MODAL
   ========================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 20px;
    color: var(--gray-900);
}

.close {
    font-size: 28px;
    font-weight: 300;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
}

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

/* ==========================================
   EMPTY STATE
   ========================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-600);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--gray-700);
}

/* ==========================================
   LEAD DETAILS PAGE
   ========================================== */
.lead-header {
    background: white;
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.lead-header h2 {
    font-size: 28px;
    margin-bottom: 16px;
    color: var(--gray-900);
}

.lead-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-600);
    font-size: 14px;
}

.meta-item strong {
    color: var(--gray-900);
}

.grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--gray-900);
    border-bottom: 2px solid var(--gray-200);
    padding-bottom: 12px;
}

.info-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.info-label {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 14px;
}

.info-value {
    color: var(--gray-900);
    font-size: 14px;
}

.symptom-tag {
    display: inline-block;
    background: var(--status-new-bg);
    color: var(--status-new-text);
    padding: 6px 12px;
    margin: 4px 4px 0 0;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
}

.description-box {
    background: var(--gray-50);
    border-left: 4px solid var(--primary);
    padding: 16px;
    border-radius: var(--radius);
    color: var(--gray-700);
    line-height: 1.6;
    white-space: pre-wrap;
}

.score-display {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    color: white;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.score-number {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 8px;
}

.score-label {
    font-size: 14px;
    opacity: 0.9;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }
    
    .stats {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    table {
        font-size: 13px;
    }
    
    th, td {
        padding: 12px 8px;
    }
}

@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .user-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters > * {
        width: 100%;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        text-align: center;
    }
}

/* ==========================================
   SIDEBAR NAVIGATION
   ========================================== */
:root {
    --sidebar-width: 260px;
}

.crm-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 1100;
    overflow-y: auto;
}

.sidebar-nav {
    flex: 1;
    list-style: none;
    margin: 0;
    padding: 16px 0;
}

.nav-section {
    padding: 16px 20px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.nav-item {
    margin: 2px 8px;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.nav-item a:hover,
.nav-item.active a {
    background: var(--gray-100);
    color: var(--gray-900);
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--gray-600);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.logout-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* Main content with sidebar */
body.has-sidebar .header {
    margin-left: var(--sidebar-width);
}

body.has-sidebar .container {
    margin-left: var(--sidebar-width);
}

/* Mobile responsive sidebar */
@media (max-width: 768px) {
    .crm-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-xl);
    }
    
    .crm-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Don't push content on mobile */
    body.has-sidebar .header {
        margin-left: 0;
    }
    
    body.has-sidebar .container {
        margin-left: 0;
    }
    
    /* Push header content to avoid button overlap */
    .header-content {
        padding-left: 60px;
    }
    
    /* Close button for sidebar */
    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 16px 20px;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .sidebar-close-btn {
        background: transparent;
        border: none;
        font-size: 28px;
        color: var(--gray-500);
        cursor: pointer;
        padding: 4px 8px;
        line-height: 1;
    }
    
    .mobile-menu-btn {
        position: fixed;
        top: 24px;
        left: 20px;
        z-index: 1050;
        background: transparent;
        border: none;
        padding: 0;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .mobile-menu-btn svg {
        display: none;
    }
    
    /* Hamburger lines */
    .mobile-menu-btn::before,
    .mobile-menu-btn::after,
    .mobile-menu-btn span {
        content: '';
        display: block;
        width: 24px;
        height: 2px;
        background: white;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-btn span {
        width: 24px;
        height: 2px;
        background: white;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1099;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
    
    .sidebar-close {
        display: none;
    }
}

/* ============================================================================
   PLATFORM ADDITIONS — append to crm-styles.css
   ============================================================================ */

/* Two-column form grid */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .form-row-2 { grid-template-columns: 1fr; }
}

/* Create/edit panels (collapsible) */
.create-panel {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    display: none;
}
.create-panel.open { display: block; }

/* Generic data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.data-table th {
    background: #f9fafb;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    border-bottom: 1px solid #e5e7eb;
}
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }
.data-table .text-center { text-align: center; }
.row-inactive td { opacity: 0.5; }

/* Org type badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-org-parent     { background: #dbeafe; color: #1e40af; }
.badge-org-company    { background: #d1fae5; color: #065f46; }
.badge-org-subsidiary { background: #fef3c7; color: #92400e; }
.badge-org-location   { background: #f3f4f6; color: #374151; }

/* Sidebar nav Material Icons sizing */
.sidebar-nav .nav-item a .material-icons-outlined {
    font-size: 20px;
    flex-shrink: 0;
}

/* Org logo in sidebar */
.sidebar-org-logo {
    padding: 12px 0 8px;
    text-align: center;
}
.sidebar-org-logo img {
    max-width: 140px;
    max-height: 48px;
    width: auto;
    height: auto;
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

/* Org switcher */
.sidebar-org-switcher {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 4px;
}
.org-switcher-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 8px;
}
.org-switcher-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    appearance: auto;
    transition: border-color 0.2s ease;
}
.org-switcher-select:hover {
    border-color: var(--gray-300);
}
.org-switcher-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* Accordion nav sections */
.nav-section-accordion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 16px 20px 8px;
}
.nav-section-accordion:hover {
    color: var(--gray-700);
}
.nav-section-chevron {
    font-size: 18px !important;
    color: var(--gray-400);
    transition: transform 0.2s ease;
}
.nav-section-items {
    display: block;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}
.nav-section-items ul {
    list-style: none;
    margin: 0;
    padding: 0 0 4px 0;
}
.nav-section-items.open {
    max-height: none;
}

/* Disabled nav item (Email Blasts placeholder) */
.nav-item-disabled a {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}
.nav-item-soon {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--gray-100);
    color: var(--gray-400);
    padding: 2px 6px;
    border-radius: 10px;
}

/* Sidebar user info */
.sidebar-user {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    margin-bottom: 8px;
}
.user-role {
    font-size: 11px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Icon buttons */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #f3f4f6;
    color: #374151;
    text-decoration: none;
    transition: background 0.15s;
}
.icon-btn:hover { background: #e5e7eb; color: #111827; }

/* Responsive data table — hide less important columns on mobile */
@media (max-width: 768px) {
    .data-table .hide-mobile { display: none; }
    .data-table td, .data-table th { padding: 10px 8px; font-size: 13px; }
    .action-links { flex-direction: column; gap: 4px; }
    .action-links a { font-size: 12px; }
}

/* Utility */
.text-muted  { color: #6b7280; }
.text-sm     { font-size: 12px; }
.text-center { text-align: center; }
/* ==========================================
   DASHBOARD — ORG VIEW
   ========================================== */

/* Stat card sub-label (e.g. "12 this month") */
.stat-sub {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* Trend pill on stat number (↑12% / ↓5%) */
.trend-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    vertical-align: middle;
    margin-left: 6px;
}
.trend-up   { background: var(--status-qualified-bg);     color: var(--status-qualified-text); }
.trend-down { background: var(--status-disqualified-bg);  color: var(--status-disqualified-text); }
.trend-flat { background: var(--gray-100);                color: var(--gray-500); }

/* 30-day sparkline canvas */
.spark-canvas {
    display: block;
    width: 100%;
    height: 56px;
}

/* Activity feed */
.activity-feed {
    list-style: none;
    margin: 0;
    padding: 0;
}
.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
    align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-100);
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
}
.activity-icon .material-icons-outlined { font-size: 16px; }
.activity-body  { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; color: var(--gray-900); line-height: 1.4; }
.activity-title a { color: var(--primary); text-decoration: none; font-weight: 600; }
.activity-title a:hover { text-decoration: underline; }
.activity-meta  { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* Quick links strip */
.quick-links { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}
.quick-link:hover { background: var(--gray-100); border-color: var(--gray-300); color: var(--gray-900); }
.quick-link .material-icons-outlined { font-size: 18px; }

/* Dashboard card heading — lighter than lead details .card h3 */
.card-heading {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.card-heading .material-icons-outlined { font-size: 18px; color: var(--primary); }
.card-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.card-heading-row .card-heading { margin-bottom: 0; }
.card-link {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
}
.card-link:hover { text-decoration: underline; }

/* ==========================================
   ORG PICKER
   ========================================== */
.org-picker {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 600px;
}

.org-picker-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--gray-900);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.org-picker-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.org-picker-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.org-picker-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

.org-picker-indent {
    color: var(--gray-400);
    font-weight: 400;
}

.org-picker-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--gray-500);
}

.org-picker-meta .material-icons-outlined {
    font-size: 16px;
}

/* ==========================================
   ASSET CARDS
   ========================================== */
.assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}
@media (max-width: 768px) {
    .assets-grid { grid-template-columns: 1fr; }
}

.asset-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: box-shadow 0.2s;
}
.asset-card:hover { box-shadow: var(--shadow-md); }

.asset-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.asset-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 8px 0;
}

.asset-type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.asset-type-landing_page   { background: #dbeafe; color: #1e40af; }
.asset-type-form           { background: #e0e7ff; color: #3730a3; }
.asset-type-email_template { background: #fce7f3; color: #9f1239; }
.asset-type-legal_page     { background: var(--gray-100); color: var(--gray-700); }
.asset-type-pdf            { background: #fee2e2; color: #991b1b; }
.asset-type-other          { background: var(--gray-100); color: var(--gray-600); }

.asset-url {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    color: var(--primary);
    word-break: break-all;
    margin: 10px 0;
    padding: 8px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}
.asset-url a { color: var(--primary); text-decoration: none; }
.asset-url a:hover { text-decoration: underline; }

.asset-stats {
    display: flex;
    gap: 20px;
    margin: 12px 0;
    padding: 12px 0;
    border-top: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
}
.asset-stat { text-align: center; }
.asset-stat-number {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}
.asset-stat-label {
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.asset-meta {
    font-size: 13px;
    color: var(--gray-500);
    margin: 12px 0;
}

.asset-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}
.status-dot-active    { background: var(--success); }
.status-dot-draft     { background: #f59e0b; }
.status-dot-paused    { background: var(--gray-400); }
.status-dot-archived  { background: var(--gray-300); }
.status-dot-published { background: var(--success); }

.org-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--gray-500);
    margin-left: 6px;
    font-weight: 400;
}

@media (max-width: 768px) {
    .asset-stats .hide-mobile { display: none; }
}

/* ==========================================
   SETTINGS PAGES — shared
   ========================================== */
.settings-section {
    margin-bottom: 24px;
}

.settings-description {
    font-size: 14px;
    color: var(--gray-500);
    line-height: 1.6;
    max-width: 680px;
}

/* ==========================================
   TOGGLE SWITCH
   ========================================== */
.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    line-height: 1;
}

.toggle-text {
    font-size: 14px;
    color: var(--gray-700);
    line-height: 1;
    position: relative;
    top: 0;
}

.toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(18px);
}



.form-group-inline {
    margin-bottom: 12px;
}

/* ==========================================
   LEAD TYPES TABLE
   ========================================== */
.lt-table-wrap {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.lt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.lt-table thead tr {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.lt-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.lt-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.lt-row:last-child td {
    border-bottom: none;
}

.lt-row:hover {
    background: var(--gray-50);
}

.lt-row-active {
    background: #f0f4ff !important;
}

.lt-label {
    font-weight: 600;
    color: var(--gray-900);
}

.lt-slug {
    font-size: 12px;
    color: var(--gray-400);
    font-family: monospace;
    margin-top: 2px;
}

.lt-template-name {
    color: var(--gray-700);
}

.lt-off {
    color: var(--gray-400);
    font-style: italic;
    font-size: 13px;
}

.lt-unset {
    color: var(--gray-400);
    font-size: 13px;
}

.lt-actions-cell {
    text-align: right;
    white-space: nowrap;
}

.status-active   { background: #d1fae5; color: #065f46; }
.status-inactive { background: var(--gray-100); color: var(--gray-500); }

/* -- Edit panel ---------------------------------------------------------------- */
.lt-panel-row td {
    padding: 0;
    border-bottom: 2px solid #c7d2fe;
}

.lt-panel-cell {
    background: #f8f9ff;
    padding: 24px !important;
}

.lt-panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.lt-panel-group {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 16px;
}

.lt-panel-group-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 14px;
}

.lt-panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lt-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 6px;
}

.lt-hint a {
    color: var(--primary);
}

@media (max-width: 768px) {
    .lt-table .hide-mobile { display: none; }
    .lt-panel-grid { grid-template-columns: 1fr; }
    .lt-panel-grid-2 { grid-template-columns: 1fr; }
    .lt-panel-strip  { flex-direction: column; align-items: flex-start; gap: 16px; }
    .lt-panel-strip-sender { width: 100%; }
}

.lt-not-configured {
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
    margin-top: 2px;
}

/* ==========================================
   LEAD TYPES — tabs, 2-card grid, bottom strip
   ========================================== */
.lt-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.lt-tab {
    padding: 8px 20px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.15s;
}

.lt-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.lt-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Two equal cards side by side */
.lt-panel-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* Full-width bottom strip: sender left, active toggle right */
.lt-panel-strip {
    display: flex;
    align-items: center;
    gap: 24px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 16px;
}

.lt-panel-strip-sender {
    flex: 1;
}

.lt-panel-strip-sender label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.lt-panel-strip-active {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

@media (max-width: 768px) {
    .lt-panel-grid-2 { grid-template-columns: 1fr; }
    .lt-panel-strip  { flex-direction: column; align-items: flex-start; gap: 16px; }
    .lt-panel-strip-sender { width: 100%; }
}

/* ==========================================
   NOTIFICATION RECIPIENTS
   ========================================== */
.nr-table-wrap {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.nr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.nr-table thead tr {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.nr-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.nr-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.nr-row:last-child td {
    border-bottom: none;
}

.nr-row:hover {
    background: var(--gray-50);
}

.nr-row-editing {
    background: #f8f9ff !important;
}

.nr-name  { font-weight: 600; color: var(--gray-900); }
.nr-email { color: var(--gray-600); }

.nr-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.nr-badge-global  { background: #dbeafe; color: #1e40af; }
.nr-badge-product { background: #fef9c3; color: #854d0e; }

.nr-unset {
    color: var(--gray-400);
    font-size: 13px;
}

.nr-actions-cell { text-align: right; white-space: nowrap; }

.nr-empty {
    text-align: center;
    padding: 32px !important;
    color: var(--gray-400);
    font-style: italic;
}

/* Edit cell — full-width replacement row */
.nr-edit-cell {
    padding: 16px !important;
    background: #f8f9ff;
    border-bottom: 2px solid #c7d2fe;
}

/* Inline form layout */
.nr-inline-form { width: 100%; }

.nr-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.nr-form-field {
    flex: 1;
    min-width: 160px;
}

.nr-form-field-narrow {
    flex: 0 0 auto;
    min-width: 130px;
}

/* Toggle fields — same bottom alignment as input fields */
.nr-form-field-toggle {
    flex: 0 0 auto;
    min-width: 130px;
}

.nr-form-field-toggle > label:first-child {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.nr-form-field-toggle .toggle-label {
    height: 36px;
    display: inline-flex;
    align-items: center;
}

.nr-form-field label,
.nr-form-field > label:first-child {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.nr-form-field input[type="text"],
.nr-form-field input[type="email"],
.nr-form-field select {
    width: 100%;
}

.nr-form-actions {
    display: flex;
    gap: 6px;
    align-items: stretch;
    flex-shrink: 0;
    align-self: flex-end;
}

.nr-form-actions .btn {
    height: 46px;
    padding-top: 0;
    padding-bottom: 0;
    display: flex;
    align-items: center;
}

.nr-delete-form {
    margin-top: 10px;
}

.btn-link-danger {
    background: none;
    border: none;
    color: var(--error-text, #b91c1c);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.btn-link-danger:hover {
    color: #7f1d1d;
}

/* Add row */
.nr-add-row td { border-bottom: none; }

.nr-add-cell {
    padding: 12px 16px !important;
}

.nr-add-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

.nr-add-header:hover { opacity: .8; }

.nr-add-icon {
    font-size: 18px;
    line-height: 1;
}

@media (max-width: 768px) {
    .nr-table .hide-mobile { display: none; }
    .nr-form-row { flex-direction: column; }
    .nr-form-field, .nr-form-field-narrow { min-width: 100%; flex: unset; }
    .nr-form-actions { width: 100%; }
}

/* nr-form-field inputs match global form-group styles */
.nr-form-field input[type="text"],
.nr-form-field input[type="email"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}

.nr-form-field input[type="text"]:focus,
.nr-form-field input[type="email"]:focus {
    outline: none;
    border-color: var(--primary);
}

.nr-form-field select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.nr-form-field select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==========================================
   EMAIL TEMPLATES — list
   ========================================== */
.et-table-wrap {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.et-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.et-table thead tr {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.et-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.et-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.et-row:last-child td { border-bottom: none; }
.et-row:hover { background: var(--gray-50); }

.et-name    { font-weight: 600; color: var(--gray-900); }
.et-subject { color: var(--gray-600); font-size: 13px; }
.et-date    { color: var(--gray-400); font-size: 13px; }

.et-type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.et-type-notification  { background: #dbeafe; color: #1e40af; }
.et-type-autoresponder { background: #d1fae5; color: #065f46; }
.et-type-campaign      { background: #fef9c3; color: #854d0e; }
.et-type-transactional { background: #f3e8ff; color: #6b21a8; }

.et-actions-cell {
    text-align: right;
    white-space: nowrap;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
    padding: 10px 16px;
}

.et-delete-btn { color: var(--error-text, #b91c1c); }

/* ==========================================
   EMAIL TEMPLATES — edit/create
   ========================================== */
.et-back-link {
    font-size: 13px;
    color: var(--gray-500);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.et-back-link:hover { color: var(--primary); }

.et-edit-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

.et-form-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    overflow: hidden;
    box-sizing: border-box;
    min-width: 0;
}

.et-form-row-2 {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 16px;
    margin-bottom: 0;
}

.et-form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* CodeMirror overrides */
.CodeMirror {
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
}

.CodeMirror-scroll {
    min-height: 480px;
}

/* Variables panel */
.et-vars-panel {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: sticky;
    top: 20px;
}

.et-vars-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.et-vars-desc {
    font-size: 12px;
    color: var(--gray-400);
    margin-bottom: 16px;
    line-height: 1.5;
}

.et-vars-desc code {
    background: var(--gray-100);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
}

.et-vars-group {
    margin-bottom: 16px;
}

.et-vars-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    margin-bottom: 6px;
}

.et-var-chip {
    display: inline-block;
    padding: 3px 8px;
    margin: 2px 2px 2px 0;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: monospace;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.15s;
}

.et-var-chip:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

@media (max-width: 1024px) {
    .et-edit-layout { grid-template-columns: 1fr; }
    .et-vars-panel  { position: static; }
}

@media (max-width: 768px) {
    .et-table .hide-mobile { display: none; }
    .et-form-row-2 { grid-template-columns: 1fr; }
    .et-actions-cell { flex-direction: row; }
}

.btn-icon-close {
    color: var(--gray-500);
}

/* ==========================================
   EMAIL SENDERS — list (card layout)
   ========================================== */
.sp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.sp-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s;
}

.sp-card:hover {
    box-shadow: var(--shadow-md);
}

.sp-card-default {
    border: 1px solid var(--gray-200);
}

.sp-card-inactive {
    opacity: 0.6;
}

.sp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.sp-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.sp-card-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.sp-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.sp-badge-default  { background: var(--primary); color: white; }
.sp-badge-inactive { background: var(--gray-100); color: var(--gray-500); }

.sp-card-details {
    border-top: 1px solid var(--gray-100);
    border-bottom: 1px solid var(--gray-100);
    padding: 12px 0;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sp-detail {
    display: flex;
    gap: 8px;
    font-size: 13px;
}

.sp-detail-label {
    font-weight: 600;
    color: var(--gray-500);
    min-width: 72px;
    flex-shrink: 0;
}

.sp-detail-value {
    color: var(--gray-700);
    word-break: break-all;
}

.sp-card-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ==========================================
   EMAIL SENDERS — edit form
   ========================================== */
.sp-form-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.field-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 5px;
}

.field-optional {
    font-size: 12px;
    font-weight: 400;
    color: var(--gray-400);
    text-transform: none;
    letter-spacing: 0;
}

.sp-key-set {
    font-size: 12px;
    font-weight: 600;
    color: #065f46;
    background: #d1fae5;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    margin-left: 8px;
    vertical-align: middle;
}

.sp-key-field {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sp-key-field input {
    flex: 1;
}

@media (max-width: 768px) {
    .sp-grid { grid-template-columns: 1fr; }
}

/* ==========================================
   LEADS LIST
   ========================================== */
.leads-stats-bar {
    display: flex;
    gap: 24px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.leads-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.leads-stat-number {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.leads-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    font-weight: 600;
}

.leads-table-wrap {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.leads-table thead tr {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.leads-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.leads-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.leads-row {
    cursor: pointer;
    transition: background 0.1s;
}

.leads-row:hover { background: var(--gray-50); }
.leads-row:last-child td { border-bottom: none; }

.leads-name  { font-weight: 600; color: var(--gray-900); }
.leads-email { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.leads-type  { font-size: 13px; color: var(--gray-600); }
.leads-date  { font-size: 13px; color: var(--gray-400); }

.leads-action-cell { text-align: right; }

.lead-score {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
}

.score-high { background: #d1fae5; color: #065f46; }
.score-med  { background: #fef9c3; color: #854d0e; }
.score-low  { background: #fee2e2; color: #991b1b; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding-bottom: 8px;
}

.pagination-info {
    font-size: 14px;
    color: var(--gray-500);
}

/* ==========================================
   LEAD DETAIL
   ========================================== */
.ld-header-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.ld-type-label {
    font-size: 13px;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.ld-created {
    font-size: 13px;
    color: var(--gray-400);
    margin-left: auto;
}

.ld-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

.ld-main  { min-width: 0; }
.ld-sidebar { min-width: 0; }

.ld-notes-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.2s;
}

.ld-notes-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.ld-contact-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.score-display {
    text-align: center;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.score-number {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
}

.score-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    margin-top: 6px;
    font-weight: 600;
}

.symptom-tag {
    display: inline-block;
    padding: 3px 10px;
    background: #ede9fe;
    color: #5b21b6;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    margin: 2px;
}

.description-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 12px;
    font-size: 14px;
    color: var(--gray-700);
    line-height: 1.6;
}

/* Activity log */
.ld-activity {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ld-activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.ld-activity-item:last-child { border-bottom: none; }

.ld-activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 5px;
}

.ld-activity-action {
    font-size: 14px;
    color: var(--gray-700);
    font-weight: 500;
}

.ld-activity-meta {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

@media (max-width: 1024px) {
    .ld-grid { grid-template-columns: 1fr; }
    .ld-created { margin-left: 0; }
}

@media (max-width: 768px) {
    .leads-table .hide-mobile { display: none; }
    .leads-stats-bar { gap: 16px; padding: 12px 16px; flex-wrap: wrap; }
}

/* ==========================================
   GLOBAL INPUT / SELECT / TEXTAREA STYLES
   Applied globally so all fields match
   regardless of parent container.
   ========================================== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: var(--gray-900);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Filters bar inputs now inherit global styles,
   just need consistent height */
.filters input[type="text"],
.filters select {
    height: 40px;
    padding: 0 14px;
}

.filters select {
    padding-right: 32px;
}

/* ==========================================
   ORG PROFILE — color picker row
   ========================================== */
.op-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.op-color-row input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
    background: none;
}

.op-color-row input[type="text"] {
    flex: 1;
}

.op-logo-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.op-logo-preview img {
    max-height: 48px;
    max-width: 160px;
    object-fit: contain;
}

.op-logo-label {
    font-size: 12px;
    color: var(--gray-400);
}

.op-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.op-upload-label {
    font-size: 13px;
    color: var(--gray-400);
}
/* Delivery settings variable chips */
.delivery-vars {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}
.delivery-vars-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-400);
    margin-right: 4px;
}
.delivery-var-chip {
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-family: monospace;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.15s ease;
}
.delivery-var-chip:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
/* ==========================================
   FORMS SYSTEM
   ========================================== */

/* Required field asterisk */
.req {
    color: var(--primary);
    font-weight: 700;
    margin-left: 2px;
}

/* Variable insert row — select + icon button side by side */
.var-insert-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.var-insert-row select {
    flex: 1;
    width: 0;
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 768px) {
    .var-insert-row select {
        width: 100%;
        max-width: calc(100% - 44px);
    }
}

.var-insert-row .btn-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    color: var(--gray-500);
}

.var-insert-row .btn-icon:hover {
    background: var(--gray-200);
    color: var(--gray-700);
    opacity: 1;
}

@media (max-width: 640px) {
    .type-segment { width: 100%; }
    .type-segment-btn { flex: 1; justify-content: center; padding: 8px 12px; font-size: 12px; }
    .active-toggle-label { display: none !important; }
    .add-field-panel .form-row-3,
    .add-field-panel .form-row-2 { grid-template-columns: 1fr; }
}

/* Card section divider */
.card-section-divider {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-100);
}

/* Status badges for forms list */
.status-badge.status-active   { background: var(--status-converted-bg); color: var(--status-converted-text); }
.status-badge.status-inactive { background: var(--gray-100); color: var(--gray-500); }

/* Hide table columns on mobile — generic utility */
@media (max-width: 768px) {
    .hide-mobile { display: none; }
}

/* ==========================================
   DOCUMENT VARIABLES PAGE
   ========================================== */

.var-table-wrap {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.var-section-header {
    padding: 14px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.var-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.var-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    transition: background .1s;
}
.var-row:last-child { border-bottom: none; }
.var-row:hover { background: var(--gray-50); }
.var-row.editing { background: #f8f9ff; }

.var-tag {
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    background: var(--gray-100);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}

.var-info { flex: 1; min-width: 0; }
.var-label { font-weight: 600; font-size: 14px; color: var(--gray-900); }
.var-example { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.var-desc { font-size: 12px; color: var(--gray-400); margin-top: 2px; font-style: italic; }
.var-actions { display: flex; gap: 4px; flex-shrink: 0; align-self: center; }

.var-edit-form {
    display: none;
    padding: 16px 20px;
    background: #f8f9ff;
    border-bottom: 2px solid #c7d2fe;
}
.var-edit-form.open { display: block; }

.var-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.var-edit-actions { display: flex; gap: 8px; }

.var-add-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.system-lock {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}
.system-lock .material-icons-outlined { font-size: 13px; }

/* Forms list page */
.forms-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.forms-toolbar select { flex: 1; min-width: 120px; max-width: 200px; }
.forms-toolbar .manage-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-500);
    text-decoration: none;
    white-space: nowrap;
}
.forms-toolbar .manage-link:hover { color: var(--primary); }

.form-list { display: flex; flex-direction: column; }
.form-list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    transition: background .1s;
}
.form-list-row:last-child { border-bottom: none; }
.form-list-row:hover { background: var(--gray-50); }

.form-list-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.form-list-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.form-type-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.form-type-pill .material-icons-outlined { font-size: 12px; }
.form-type-fields   { background: var(--status-new-bg); color: var(--status-new-text); }
.form-type-document { background: #f5f3ff; color: #6d28d9; }

.form-list-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.form-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.form-status-dot.active   { background: var(--success); }
.form-status-dot.inactive { background: var(--gray-300); }

/* Forms categories page */
.cat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    transition: background .1s;
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover { background: var(--gray-50); }
.cat-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--gray-800); }
.cat-slug {
    font-size: 12px;
    font-family: monospace;
    color: var(--gray-400);
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.cat-count {
    font-size: 12px;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}
.cat-rename-form { display: none; flex: 1; align-items: center; gap: 8px; }
.cat-rename-form input {
    flex: 1;
    font-size: 14px;
    padding: 6px 10px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    outline: none;
    box-shadow: 0 0 0 3px rgba(237,32,36,.1);
}
.cat-row.renaming .cat-display { display: none; }
.cat-row.renaming .cat-rename-form { display: flex; }

@media (max-width: 640px) {
    .var-edit-grid { grid-template-columns: 1fr; }
    .var-tag { font-size: 11px; }
    .forms-toolbar select { max-width: 100%; }
    .form-list-name { max-width: 130px; }
}

/* ==========================================
   FORM EDIT PAGE
   ========================================== */
/* All form-edit specific styles — uses crm-styles.css variables throughout */

/* ── Type segmented control ─────────────────────────────────────── */
.type-segment { display:inline-flex; border:1px solid var(--gray-200); border-radius:var(--radius-md); overflow:hidden; }
.type-segment-btn {
    display:flex; align-items:center; gap:6px;
    padding:8px 18px; font-size:13px; font-weight:600;
    background:#fff; border:none; cursor:pointer;
    color:var(--gray-500); transition:background .12s, color .12s;
    position:relative; white-space:nowrap;
}
.type-segment-btn:not(:last-child) { border-right:1px solid var(--gray-200); }
.type-segment-btn .material-icons-outlined { font-size:16px; }
.type-segment-btn.active { background:var(--primary); color:#fff; }
.type-segment-btn input[type="radio"] { position:absolute; opacity:0; width:0; height:0; }
.type-segment-desc { font-size:12px; color:var(--gray-500); line-height:1.5; margin-top:8px; min-height:18px; }

/* ── Active toggle label (uses existing .toggle-label/.toggle-slider) */
.active-toggle-label { display:flex; align-items:center; gap:8px; cursor:pointer; white-space:nowrap; }

/* ── Category chips ──────────────────────────────────────────────── */
.category-chips { display:flex; flex-wrap:wrap; gap:8px; }
.category-chip {
    display:inline-flex; align-items:center; gap:6px;
    padding:5px 12px; border-radius:var(--radius-full); font-size:13px; font-weight:500;
    border:2px solid var(--gray-200); background:#fff; cursor:pointer;
    transition:border-color .15s, background .15s; user-select:none;
}
.category-chip input[type="checkbox"] { position:absolute; opacity:0; width:0; height:0; }
.category-chip.selected { border-color:var(--primary); background:var(--status-new-bg); color:var(--status-new-text); }
.category-chip .chip-check { font-size:15px; }

/* ── Document textarea ───────────────────────────────────────────── */
.doc-body-textarea {
    font-family:'Georgia', serif; font-size:14px; line-height:1.8;
    color:var(--gray-800); background:#fff;
    border:1px solid var(--gray-300); border-radius:var(--radius);
    padding:20px; width:100%; resize:vertical; min-height:420px;
}
.doc-body-textarea:focus {
    outline:none; border-color:var(--primary);
    box-shadow:0 0 0 3px rgba(237,32,36,.1);
}
.word-count { font-size:12px; color:var(--gray-400); text-align:right; margin-top:6px; }

/* ── Preview modal ───────────────────────────────────────────────── */
.preview-overlay {
    display:none; position:fixed; inset:0; background:rgba(0,0,0,.6);
    z-index:9999; overflow-y:auto; padding:40px 20px;
}
.preview-overlay.open { display:flex; align-items:flex-start; justify-content:center; }
.preview-modal {
    background:#fff; border-radius:var(--radius-lg); max-width:760px;
    width:100%; padding:40px; position:relative; margin:auto;
}
.preview-modal-close {
    position:absolute; top:16px; right:20px; background:none; border:none;
    cursor:pointer; color:var(--gray-400); font-size:28px; line-height:1;
}
.preview-modal-close:hover { color:var(--gray-900); }
.preview-label { font-size:11px; font-weight:700; letter-spacing:.1em; text-transform:uppercase; color:var(--gray-400); margin-bottom:8px; }
.preview-title { font-size:20px; font-weight:700; color:var(--gray-900); margin-bottom:24px; padding-bottom:16px; border-bottom:1px solid var(--gray-200); }
.preview-body { font-family:'Georgia', serif; font-size:14px; line-height:1.9; color:var(--gray-800); white-space:pre-wrap; }
.preview-notice { margin-top:24px; padding:12px 16px; background:#fffbeb; border:1px solid #fcd34d; border-radius:var(--radius); font-size:12px; color:#92400e; }

/* ── Field builder ───────────────────────────────────────────────── */
.field-list { display:flex; flex-direction:column; gap:8px; margin-bottom:20px; min-height:40px; }
.field-row {
    display:flex; align-items:center; gap:10px;
    background:var(--gray-50); border:1px solid var(--gray-200);
    border-radius:var(--radius); padding:10px 14px; cursor:grab; user-select:none;
    transition:box-shadow .15s, background .15s;
}
.field-row:active { cursor:grabbing; }
.field-row.dragging { opacity:.5; box-shadow:var(--shadow-md); }
.field-row.drag-over { background:var(--status-new-bg); border-color:var(--primary); }
.field-drag-handle { color:var(--gray-400); font-size:20px; flex-shrink:0; cursor:grab; }
.field-info { flex:1; min-width:0; }
.field-info-name { font-weight:600; font-size:14px; color:var(--gray-800); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.field-info-meta { font-size:12px; color:var(--gray-500); margin-top:2px; }
.field-badges { display:flex; gap:6px; flex-shrink:0; flex-wrap:wrap; }
.field-badge { font-size:11px; font-weight:600; padding:2px 8px; border-radius:var(--radius-full); background:var(--gray-100); color:var(--gray-600); }
.field-badge-phi { background:var(--status-contacted-bg); color:var(--status-contacted-text); }
.field-badge-req { background:var(--status-disqualified-bg); color:var(--status-disqualified-text); }
.field-badge-sig { background:var(--status-qualified-bg); color:var(--status-qualified-text); }
.field-badge-rep { background:#fdf4ff; color:#7e22ce; }
.field-delete-btn { background:none; border:none; color:var(--gray-400); cursor:pointer; padding:4px; border-radius:var(--radius-sm); display:flex; align-items:center; transition:color .15s; flex-shrink:0; }
.field-delete-btn:hover { color:var(--error); }
.field-list-empty { text-align:center; padding:32px; color:var(--gray-400); font-size:14px; border:2px dashed var(--gray-200); border-radius:var(--radius); }
.add-field-panel { background:var(--gray-50); border:1px solid var(--gray-200); border-radius:var(--radius-md); padding:20px; margin-top:8px; }
.add-field-panel .form-row-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }
.add-field-panel .form-row-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }

/* ── Responsive — handled in crm-styles.css ─────────────────────── */


/* ============================================================
   SESSION 7 — append to bottom of crm-styles.css
   ============================================================ */

/* ── Form card grid (replaces .form-list row pattern) ─────── */
.form-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.form-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s, border-color .2s;
}
.form-card:hover { box-shadow: var(--shadow-md); }
.form-card.inactive { opacity: .65; }
.form-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 8px 0;
    line-height: 1.3;
}
.form-card-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.form-card-description {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0 0 12px 0;
    line-height: 1.45;
    flex: 1;
}
.form-card-meta {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.form-card-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
}
.form-card-status.active   { background: #dcfce7; color: #166534; }
.form-card-status.inactive { background: var(--gray-100); color: var(--gray-500); }
.form-card-actions { display: flex; gap: 4px; align-items: center; }
.form-cat-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ── Package card grid ──────────────────────────────────────── */
.pkg-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.pkg-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s;
}
.pkg-card:hover { box-shadow: var(--shadow-md); }
.pkg-card.inactive { opacity: .65; }
.pkg-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 6px 0;
}
.pkg-category-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: #eff6ff;
    color: #1d4ed8;
    margin-bottom: 10px;
    align-self: flex-start;
}
.pkg-card-description {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0 0 12px 0;
    line-height: 1.45;
    flex: 1;
}
.pkg-card-meta {
    font-size: 12px;
    color: var(--gray-400);
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.pkg-card-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--gray-500);
}
.pkg-card-stat .material-icons-outlined { font-size: 14px; }
.pkg-card-actions { display: flex; gap: 4px; }
.pkg-card-status {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
}
.pkg-card-status.active   { background: #dcfce7; color: #166534; }
.pkg-card-status.inactive { background: var(--gray-100); color: var(--gray-500); }

/* ── Packages toolbar ────────────────────────────────────────── */
.pkgs-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.pkgs-toolbar select { flex: 1; min-width: 120px; max-width: 200px; }

/* ── Package sequence builder ────────────────────────────────── */
.pkg-builder-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 4px;
}
.pkg-panel {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.pkg-panel-header {
    background: var(--gray-50);
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pkg-panel-body {
    min-height: 160px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pkg-panel-empty {
    text-align: center;
    padding: 28px 12px;
    color: var(--gray-400);
    font-size: 13px;
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    margin: 4px;
}
.pkg-panel-filter {
    padding: 8px;
    border-bottom: 1px solid var(--gray-100);
}
.pkg-panel-filter select {
    width: 100%;
    font-size: 12px;
    padding: 5px 8px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
}
.pkg-form-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: white;
    border: 1px solid var(--gray-100);
    font-size: 13px;
    transition: background .1s, border-color .1s;
}
.pkg-form-row:hover { background: var(--gray-50); border-color: var(--gray-200); }
.pkg-form-row.dragging { opacity: .45; box-shadow: var(--shadow-md); }
.pkg-form-row.drag-over { background: var(--status-new-bg); border-color: var(--primary); }
.pkg-form-row-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pkg-seq-handle { color: var(--gray-300); font-size: 18px; cursor: grab; flex-shrink: 0; }
.pkg-seq-num { font-size: 11px; font-weight: 700; color: var(--gray-400); min-width: 16px; text-align: center; flex-shrink: 0; }
.pkg-add-btn {
    background: none; border: none; color: var(--primary);
    cursor: pointer; padding: 2px; border-radius: var(--radius-sm);
    display: flex; align-items: center; font-size: 18px; flex-shrink: 0;
    transition: background .1s;
}
.pkg-add-btn:hover { background: #fef2f2; }
.pkg-remove-btn {
    background: none; border: none; color: var(--gray-300);
    cursor: pointer; padding: 2px; border-radius: var(--radius-sm);
    display: flex; align-items: center; font-size: 18px; flex-shrink: 0;
    transition: color .15s;
}
.pkg-remove-btn:hover { color: var(--error); }

/* ── Send Forms modal ────────────────────────────────────────── */
.send-modal-content {
    background: white;
    margin: 5% auto;
    padding: 0;
    border-radius: var(--radius-lg);
    width: 92%;
    max-width: 540px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}
.send-modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.send-modal-header h2 { font-size: 18px; font-weight: 700; color: var(--gray-900); margin: 0; }
.send-modal-steps {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    gap: 4px;
}
.send-modal-step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-400);
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
}
.send-modal-step.active { color: var(--primary); }
.send-modal-step.done   { color: var(--success); }
.send-step-dot {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
    transition: all .2s;
}
.send-modal-step.active .send-step-dot { border-color: var(--primary); background: var(--primary); color: white; }
.send-modal-step.done   .send-step-dot { border-color: var(--success); background: var(--success); color: white; }
.send-step-connector { flex: 1; height: 2px; background: var(--gray-200); margin: 0 2px; max-width: 40px; }
.send-step-connector.done { background: var(--success); }
.send-modal-body { padding: 24px; min-height: 180px; }
.send-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.send-modal-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    color: #991b1b;
    margin-bottom: 16px;
    display: none;
}
.pkg-seq-preview {
    margin-top: 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.pkg-seq-preview-header {
    background: var(--gray-50);
    padding: 7px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--gray-400);
    border-bottom: 1px solid var(--gray-100);
}
.pkg-seq-preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
}
.pkg-seq-preview-row:last-child { border-bottom: none; }
.pkg-seq-preview-num { font-size: 11px; font-weight: 700; color: var(--gray-400); min-width: 16px; }
.custom-var-field { margin-bottom: 16px; }
.custom-var-field label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
.custom-var-field .var-tag-hint { font-size: 11px; font-family: monospace; color: var(--gray-400); font-weight: 400; margin-left: 6px; }
.custom-var-field input { width: 100%; box-sizing: border-box; }
.send-confirm-block {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}
.send-confirm-row { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; font-size: 13px; }
.send-confirm-row:last-child { margin-bottom: 0; }
.send-confirm-label { font-weight: 600; color: var(--gray-500); min-width: 80px; flex-shrink: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.send-confirm-value { color: var(--gray-800); font-weight: 500; }

/* ── Lead detail Send Forms card ─────────────────────────────── */
.ld-send-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; }

@media (max-width: 640px) {
    .form-card-grid  { grid-template-columns: 1fr; }
    .pkg-card-grid   { grid-template-columns: 1fr; }
    .pkg-builder-panels { grid-template-columns: 1fr; }
    .send-modal-content { margin: 0; border-radius: 0; width: 100%; max-width: 100%; min-height: 100vh; }
}
/* ═══════════════════════════════════════════════════════════════════════════
   UNIFIED BLOCK BUILDER — forms_edit.php
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Document block row ─────────────────────────────────────────────────── */
.block-row {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: grab;
}
.block-row-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    user-select: none;
}
.block-row-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
    flex-shrink: 0;
}
.block-row-preview {
    font-size: 12px;
    color: var(--gray-400);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}
.block-type-pill {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

/* ── Signature block row variant ────────────────────────────────────────── */
.sig-row {
    border-left-color: var(--gray-400);
}

/* ── Add block buttons ──────────────────────────────────────────────────── */
.add-block-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px dashed var(--primary);
    border-radius: 6px;
    background: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.add-block-btn:hover {
    background: rgba(237,32,36,.05);
}
.add-block-btn.sig {
    border-color: var(--gray-400);
    color: var(--gray-600);
}
.add-block-btn.sig:hover {
    background: var(--gray-50);
}

/* ═══════════════════════════════════════════════════════════════════════════
   UNIFIED MODAL — block editor + preview (forms_edit.php)
   One overlay, two content modes.
   ═══════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.modal-overlay.open {
    display: flex;
}
.modal-box {
    background: var(--white, #fff);
    border-radius: 10px;
    width: 100%;
    max-width: 780px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}
.modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-800);
}
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 22px;
    line-height: 1;
    padding: 0;
}
.modal-close:hover {
    color: var(--gray-700);
}
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.modal-body.editor {
    display: flex;
    flex-direction: column;
}
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* ── Preview content inside modal ───────────────────────────────────────── */
.modal-preview-rendered {
    font-size: 13px;
    line-height: 1.7;
    color: var(--gray-700);
    font-family: Georgia, serif;
    /* white-space: pre-wrap removed — content is now rich HTML from TinyMCE */
}
/* Rich content elements inside preview */
.modal-preview-rendered p          { margin-bottom: 0.7em; }
.modal-preview-rendered p:last-child { margin-bottom: 0; }
.modal-preview-rendered strong     { font-weight: 700; }
.modal-preview-rendered em         { font-style: italic; }
.modal-preview-rendered table      { border-collapse: collapse; width: 100%; margin-bottom: 0.7em; font-size: inherit; }
.modal-preview-rendered td,
.modal-preview-rendered th         { padding: 3px 6px; vertical-align: top; }
.modal-preview-rendered ul,
.modal-preview-rendered ol         { margin: 0.4em 0 0.7em 1.4em; }
.modal-preview-rendered li         { margin-bottom: 0.2em; }
.modal-preview-rendered hr         { border: none; border-top: 1px solid var(--gray-300); margin: 1em 0; }
.modal-preview-notice {
    font-size: 12px;
    color: var(--gray-400);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 16px;
}

@media (max-width: 640px) {
    .modal-box {
        max-height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
}