/* File: app/static/css/main.css - UNIFIED DESIGN SYSTEM */

/*
==================================================================
UNIFIED CSS VARIABLES — Single source of truth
All other CSS files reference these variables.
==================================================================
*/

:root {
    /* Brand */
    --primary-blue: #1e3a8a;
    --primary-blue-light: #3b82f6;
    --primary-blue-dark: #1e40af;
    --accent-blue: #0ea5e9;

    /* Neutrals */
    --white: #ffffff;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;

    /* Semantic */
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --info: #3b82f6;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.15);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Typography */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;

    /* Z-index scale */
    --z-sticky: 100;
    --z-dropdown: 200;
    --z-modal-backdrop: 900;
    --z-modal: 1000;
    --z-toast: 1100;

    /* BACKWARD COMPAT aliases — allows old variable names to keep working */
    --clean-white: var(--white);
    --background-light: var(--bg-page);
    --background-card: var(--bg-card);
    --text-dark: var(--text-primary);
    --text-medium: var(--text-secondary);
    --text-light: var(--text-muted);
    --border-light: var(--border);
    --success-green: var(--success);
    --warning-orange: var(--warning);
    --danger-red: var(--danger);
    --info-blue: var(--info);
    --conditional-amber: var(--warning);
    --shadow-light: var(--shadow-sm);
    --shadow-medium: var(--shadow-md);
    --shadow-strong: var(--shadow-lg);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: 48px;
    text-decoration: none;
    margin: var(--space-1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: var(--white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-blue-light) 0%, var(--primary-blue) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    background: var(--bg-page);
    border-color: var(--primary-blue);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    color: var(--white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
    color: var(--white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
}
.btn-danger:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, var(--warning-dark) 100%);
    color: var(--white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
}
.btn-warning:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-info {
    background: linear-gradient(135deg, var(--info) 0%, var(--primary-blue) 100%);
    color: var(--white);
    border: 2px solid transparent;
    box-shadow: var(--shadow-sm);
}
.btn-info:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
}
.btn-icon.btn-success { background: var(--success); }
.btn-icon.btn-danger { background: var(--danger); }

.btn-ghost {
    background: rgba(255,255,255,0.2);
    color: var(--white);
    border: 1px solid rgba(255,255,255,0.3);
}
.btn-ghost:hover { background: rgba(255,255,255,0.3); }

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: var(--white);
    padding: var(--space-4);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-md);
}

/* ===== NAVIGATION TABS ===== */
.nav-tab {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    background: var(--white);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
}
.nav-tab:hover {
    color: var(--primary-blue);
    background: var(--bg-page);
    text-decoration: none;
    border-color: var(--primary-blue);
}
.nav-tab.active {
    color: var(--white);
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    font-weight: 600;
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid transparent;
}
.status-draft { background: rgba(100, 116, 139, 0.15); color: #475569; border-color: rgba(100, 116, 139, 0.3); }
.status-completed { background: rgba(59, 130, 246, 0.15); color: #1e40af; border-color: rgba(59, 130, 246, 0.3); }
.status-submitted { background: rgba(14, 165, 233, 0.15); color: #0c4a6e; border-color: rgba(14, 165, 233, 0.3); }
.status-pass { background: rgba(16, 185, 129, 0.15); color: #065f46; border-color: rgba(16, 185, 129, 0.3); }
.status-fail { background: rgba(220, 38, 38, 0.15); color: #991b1b; border-color: rgba(220, 38, 38, 0.3); }
.status-conditional { background: rgba(245, 158, 11, 0.15); color: #92400e; border-color: rgba(245, 158, 11, 0.3); }

/* ===== ALERTS (flat style) ===== */
.alert {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background-color: #f0fff4; border-left-color: #22c55e; color: #15803d; }
.alert-error { background-color: #fef2f2; border-left-color: #ef4444; color: #dc2626; }
.alert-warning { background-color: #fffbeb; border-left-color: var(--warning); color: var(--warning-dark); }
.alert-info { background-color: #eff6ff; border-left-color: var(--info); color: #2563eb; }

/* ===== FLASH MESSAGES ===== */
.flash-messages { margin: 20px 0; }
.flash-message {
    padding: 12px 40px 12px 16px;
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    position: relative;
    animation: slideIn 0.3s ease;
}
.flash-message.success { background-color: #f0fff4; border-left-color: #22c55e; color: #15803d; }
.flash-message.error { background-color: #fef2f2; border-left-color: #ef4444; color: #dc2626; }
.flash-message.warning { background-color: #fffbeb; border-left-color: var(--warning); color: var(--warning-dark); }
.flash-message.info { background-color: #eff6ff; border-left-color: var(--info); color: #2563eb; }
.flash-icon { font-size: 18px; flex-shrink: 0; }
.flash-text { flex: 1; }
.flash-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    color: inherit;
    padding: 4px 8px;
    line-height: 1;
}
.flash-close:hover { opacity: 1; }

/* ===== AUTH / LANDING PAGES ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-blue) 0%, #0f172a 100%);
    padding: var(--space-4);
    position: relative;
    overflow: hidden;
}
.auth-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}
.auth-wrapper::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}
.auth-card {
    background: var(--white);
    padding: var(--space-10);
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    max-width: 440px;
    width: 100%;
    position: relative;
    z-index: 1;
}
.auth-logo {
    text-align: center;
    margin-bottom: var(--space-8);
}
.auth-logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
    color: var(--white);
    font-size: 1.75rem;
}
.auth-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-2) 0;
    line-height: 1.2;
}
.auth-subtitle {
    color: var(--text-secondary);
    font-size: var(--text-base);
    margin: 0;
}
.auth-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--white);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
    box-sizing: border-box;
}
.auth-input:focus {
    outline: none;
    border-color: var(--primary-blue-light);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}
.auth-input::placeholder { color: var(--text-muted); }
.auth-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
}
.auth-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--text-base);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}
.auth-btn:hover {
    box-shadow: 0 8px 24px rgba(30, 58, 138, 0.4);
    transform: translateY(-1px);
}
.auth-notice {
    margin-top: var(--space-6);
    padding: var(--space-4);
    background: var(--bg-page);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
}

/* ===== LANDING PAGE ===== */
.landing-features {
    background: var(--bg-page);
    padding: 80px var(--space-4);
}
.landing-features-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-8);
}
.landing-feature-card {
    background: var(--white);
    padding: var(--space-8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: all var(--transition-normal);
    border: 1px solid var(--border);
}
.landing-feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-blue-light);
}
.landing-feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
    font-size: 1.5rem;
    color: var(--white);
}
.landing-feature-card h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-3) 0;
}
.landing-feature-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    font-size: var(--text-sm);
}

/* ===== DASHBOARD ===== */
.dashboard { padding: var(--space-6); max-width: 1400px; margin: 0 auto; }
.dashboard-welcome {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #0f172a 100%);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    color: var(--white);
    margin-bottom: var(--space-6);
    position: relative;
    overflow: hidden;
}
.dashboard-welcome::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, transparent 70%);
    border-radius: 50%;
}
.dashboard-welcome h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin: 0 0 var(--space-2) 0;
    position: relative;
    z-index: 1;
}
.dashboard-welcome p {
    opacity: 0.8;
    margin: 0;
    font-size: var(--text-sm);
    position: relative;
    z-index: 1;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.kpi-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: all var(--transition-normal);
}
.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.kpi-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}
.kpi-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: var(--space-1);
}
.kpi-sub { font-size: var(--text-xs); color: var(--text-muted); }

/* Dashboard action cards */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.action-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-normal);
}
.action-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-blue-light);
}
.action-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}
.action-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--white);
    flex-shrink: 0;
}
.action-card h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.action-card h3 + span {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}
.action-card-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.action-card-buttons .btn {
    margin: 0;
    justify-content: center;
}
.action-card-footer {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-align: center;
}

/* Outlined button variant */
.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    background: rgba(30, 58, 138, 0.04);
}

/* ===== RESPONSIVE GRID ===== */
@media (max-width: 768px) {
    .dashboard { padding: var(--space-4); }
    .dashboard-welcome { padding: var(--space-6); }
    .dashboard-welcome h1 { font-size: var(--text-xl); }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .action-grid { grid-template-columns: 1fr; }
    .auth-card { padding: var(--space-6); margin: var(--space-4); }
    .landing-features { padding: 40px var(--space-4); }
}

/* ===== LIST CARD PATTERN (companies, prospects, etc.) ===== */
/* Convert blue-block list items to clean white cards on desktop */
.company-card,
.prospect-card {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    overflow: hidden;
}
.company-card:hover,
.prospect-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-blue-light) !important;
}

/* Override the blue header backgrounds on desktop */
@media (min-width: 769px) {
    .company-header,
    .prospect-header {
        background: var(--white) !important;
        color: var(--text-primary) !important;
        border-left: 4px solid var(--primary-blue);
    }
    .company-header:hover,
    .prospect-header:hover {
        background: var(--bg-page) !important;
    }
    /* Fix text colors inside the now-white headers */
    .company-header div,
    .company-header span,
    .prospect-header div,
    .prospect-header span {
        color: inherit !important;
    }
    /* Restore subtle opacity text */
    .company-header [style*="opacity: 0.9"],
    .prospect-header [style*="opacity: 0.9"] {
        color: var(--text-secondary) !important;
        opacity: 1 !important;
    }
    /* Fix the View/Call buttons on white background */
    .company-header .btn,
    .prospect-header .btn {
        background: var(--primary-blue) !important;
        color: var(--white) !important;
        border-radius: var(--radius-sm);
    }
    /* Status-colored left borders for prospects based on overdue state */
    .prospect-card:has(.prospect-header [style*="background: #"]) .prospect-header {
        border-left-color: var(--primary-blue);
    }
    /* Due date badges */
    .company-header .due-date-badge {
        color: var(--text-secondary) !important;
        font-weight: 500;
    }
    .company-header .due-date-badge[style*="fca5a5"] {
        color: var(--danger) !important;
    }
    .company-header .due-date-badge[style*="fde68a"] {
        color: var(--warning) !important;
    }
    .company-header .due-date-badge[style*="bbf7d0"] {
        color: var(--success) !important;
    }
    /* Expand icon */
    .company-header .expand-icon,
    .prospect-header .expand-icon {
        color: var(--text-muted) !important;
    }
}

/* Status-colored left borders on prospect cards */
@media (min-width: 769px) {
    .prospect-card[data-status="new"] .prospect-header { border-left-color: var(--primary-blue-light); }
    .prospect-card[data-status="follow_up"] .prospect-header { border-left-color: var(--warning); }
    .prospect-card[data-status="estimate_sent"] .prospect-header { border-left-color: #8b5cf6; }
    .prospect-card[data-status="converted"] .prospect-header { border-left-color: var(--success); }
    .prospect-card[data-status="declined"] .prospect-header { border-left-color: var(--danger); }
}

/* Keep blue/colored style on mobile — works better for touch */
@media (max-width: 768px) {
    .company-header .btn,
    .prospect-header .btn {
        font-size: 0.8rem;
    }
}

/* ===== PAGE HEADER PATTERN ===== */
/* Standardize the top header cards across all list pages */
.card[style*="gradient"][style*="color: white"] h2,
.card[style*="gradient"][style*="color: white"] p {
    color: white !important;
}

/* ===== GLOBAL RESETS & BASE STYLES ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    background: var(--bg-page);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
select, input, textarea { max-width: 100%; }
.content { overflow-x: hidden; padding: var(--space-4); }
.content.no-padding { padding: 0; }

/* ===== GLOBAL TYPOGRAPHY ===== */
h1 { font-size: var(--text-2xl); font-weight: 700; margin: 0 0 var(--space-4) 0; line-height: 1.2; }
h2 { font-size: var(--text-xl); font-weight: 600; margin: 0 0 var(--space-3) 0; line-height: 1.3; }
h3 { font-size: var(--text-lg); font-weight: 600; margin: 0 0 var(--space-3) 0; }
h4, h5, h6 { font-weight: 600; margin: 0 0 var(--space-2) 0; }
p { margin: 0 0 var(--space-3) 0; }
small { font-size: var(--text-sm); }

/* ===== GLOBAL FORM STYLING ===== */
/* These target common Bootstrap class names that aren't loaded */
.form-control,
.form-select,
select.form-select,
input.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--white);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-blue-light);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}
.form-label,
label.form-label {
    display: block;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-check-input { margin-right: var(--space-2); }

/* ===== GLOBAL CARD STYLING ===== */
/* Override bare .card used throughout templates */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}
/* Ensure inline color:white is not overridden on colored cards */
.card[style*="background"] h1,
.card[style*="background"] h2,
.card[style*="background"] h3,
.card[style*="background"] h4,
.card[style*="background"] h5,
.card[style*="background"] h6,
.card[style*="background"] p,
.card[style*="background"] span,
.card[style*="background"] small,
.card[style*="background"] div,
.card[style*="gradient"] h1,
.card[style*="gradient"] h2,
.card[style*="gradient"] h3,
.card[style*="gradient"] h4,
.card[style*="gradient"] h5,
.card[style*="gradient"] h6,
.card[style*="gradient"] p,
.card[style*="gradient"] span,
.card[style*="gradient"] small,
.card[style*="gradient"] div {
    color: inherit;
}
.card-header {
    background: var(--bg-page);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) var(--space-5) calc(-1 * var(--space-5));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    font-weight: 600;
}
.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-info {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: var(--white);
    border-bottom: none;
}
.card-header.bg-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
}
.card-body { padding: 0; }
.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    margin: var(--space-5) calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) calc(-1 * var(--space-5));
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: var(--bg-page);
}

/* ===== BOOTSTRAP GRID POLYFILL ===== */
/* Minimal grid system so existing Bootstrap classes work */
.container-fluid { max-width: 1400px; margin: 0 auto; padding: 0 var(--space-4); }
.row { display: flex; flex-wrap: wrap; margin: 0 calc(-1 * var(--space-3)); }
.row > [class*="col"] { padding: 0 var(--space-3); }
.col-12 { width: 100%; }
.col-md-2 { width: 16.66%; }
.col-md-3 { width: 25%; }
.col-md-4 { width: 33.33%; }
.col-md-6 { width: 50%; }
.col-md-8 { width: 66.66%; }
.col-lg-4 { width: 33.33%; }
.col-lg-6 { width: 50%; }
.col-lg-8 { width: 66.66%; }
.col-lg-10 { width: 83.33%; }
.offset-lg-1 { margin-left: 8.33%; }
.g-4 { gap: var(--space-4); }

@media (max-width: 992px) {
    .col-lg-4, .col-lg-6, .col-lg-8, .col-lg-10 { width: 100%; }
    .offset-lg-1 { margin-left: 0; }
}
@media (max-width: 768px) {
    .col-md-2, .col-md-3, .col-md-4, .col-md-6, .col-md-8 { width: 100%; }
    .row { margin: 0; }
    .row > [class*="col"] { padding: 0; margin-bottom: var(--space-3); }
}

/* ===== BOOTSTRAP UTILITY POLYFILL ===== */
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-block { display: block; }
.d-none { display: none; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-white { color: var(--white); }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary-blue); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.w-100 { width: 100%; }
.h-100 { height: 100%; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.me-2 { margin-right: var(--space-2); }
.me-3 { margin-right: var(--space-3); }
.ms-2 { margin-left: var(--space-2); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.rounded { border-radius: var(--radius-md); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.border-0 { border: none; }
.bg-light { background: var(--bg-page); }
.bg-primary { background: var(--primary-blue); }
.bg-success { background: var(--success); }
.bg-danger { background: var(--danger); }
.bg-warning { background: var(--warning); }
.lead { font-size: var(--text-lg); opacity: 0.9; }
.h5 { font-size: var(--text-lg); font-weight: 600; }
.display-5 { font-size: var(--text-2xl); font-weight: 700; }
hr { border: none; border-top: 1px solid var(--border); margin: var(--space-4) 0; }

/* Bootstrap btn variants used in templates */
.btn-outline-primary { background: transparent; border: 2px solid var(--primary-blue); color: var(--primary-blue); }
.btn-outline-primary:hover { background: var(--primary-blue); color: var(--white); }
.btn-outline-danger { background: transparent; border: 2px solid var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: var(--white); }
.btn-outline-success { background: transparent; border: 2px solid var(--success); color: var(--success); }
.btn-outline-success:hover { background: var(--success); color: var(--white); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: var(--text-sm); min-height: 36px; }
.btn-lg { padding: 1rem 2rem; font-size: var(--text-lg); }
.btn-full, .btn-block { width: 100%; }
.input-group { display: flex; }
.input-group .input-group-text { padding: 10px 12px; background: var(--bg-page); border: 2px solid var(--border); border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-size: var(--text-sm); color: var(--text-secondary); display: flex; align-items: center; }
.input-group .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group-sm .form-control { padding: 6px 10px; font-size: var(--text-sm); }
.input-group-sm .input-group-text { padding: 6px 10px; }

/* Table styling */
.table, table.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}
.table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-page);
    border-bottom: 2px solid var(--border);
}
.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-sm);
}
.table-responsive { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
.table tbody tr:hover { background: rgba(59, 130, 246, 0.03); }

/* Responsive tables — convert to stacked cards on mobile */
@media (max-width: 768px) {
    .table thead { display: none; }
    .table tbody tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-3);
        padding: var(--space-3);
        box-shadow: var(--shadow-sm);
    }
    .table tbody tr:hover { background: var(--bg-card); }
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: var(--space-2) 0;
        border-bottom: 1px solid var(--border);
        font-size: var(--text-sm);
    }
    .table td:last-child { border-bottom: none; }
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        margin-right: var(--space-4);
        flex-shrink: 0;
    }
}

/* Badge styles */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}
.badge.bg-danger { background: rgba(220, 38, 38, 0.1); color: var(--danger); }
.badge.bg-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge.bg-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning-dark); }
.badge.bg-primary { background: rgba(59, 130, 246, 0.1); color: var(--primary-blue); }
.badge.bg-secondary { background: rgba(100, 116, 139, 0.1); color: var(--text-secondary); }

/* Alert styles for Bootstrap classes */
.alert.alert-warning { background: #fffbeb; border-left: 4px solid var(--warning); color: var(--warning-dark); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); }
.alert.alert-danger { background: #fef2f2; border-left: 4px solid var(--danger); color: var(--danger); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); }
.alert.alert-success { background: #f0fff4; border-left: 4px solid var(--success); color: #15803d; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); }

/* Collapse polyfill (used in estimate form) */
.collapse { display: none; }
.collapse.show { display: block; }

/* ===== FORM INPUTS ===== */
.form-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

/* ===== LINKS ===== */
a { color: var(--primary-blue); text-decoration: none; transition: color var(--transition-normal); }
a:hover { color: var(--primary-blue-light); text-decoration: underline; }

/* ===== CARDS ===== */
.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: var(--primary-blue);
}

/* ===== LIST ITEMS ===== */
.list-item:hover {
    background: var(--bg-page);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-blue);
}
.list-item-title {
    font-weight: 600;
    color: var(--primary-blue);
    margin-bottom: var(--space-1);
}

/* ===== PROGRESS BAR ===== */
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--accent-blue) 100%);
    transition: width 0.4s ease;
    border-radius: 3px;
    position: relative;
}
.progress-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShimmer 2s infinite;
}

/* ===== VALIDATION STATES ===== */
.field-completed { border-left: 4px solid var(--success); background: linear-gradient(90deg, rgba(16, 185, 129, 0.03) 0%, transparent 100%); }
.field-error { border-left: 4px solid var(--danger); background: linear-gradient(90deg, rgba(220, 38, 38, 0.05) 0%, transparent 100%); }
.field-warning { border-left: 4px solid var(--warning); background: linear-gradient(90deg, rgba(245, 158, 11, 0.03) 0%, transparent 100%); }

/* ===== PRESSURE READING VALIDATION ===== */
.pressure-reading-good { background: rgba(16, 185, 129, 0.15); color: #065f46; border: 2px solid var(--success); padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-weight: 600; }
.pressure-reading-fail { background: rgba(220, 38, 38, 0.15); color: #991b1b; border: 2px solid var(--danger); padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-weight: bold; animation: failPulse 0.5s ease; }
.pressure-reading-warning { background: rgba(245, 158, 11, 0.15); color: #92400e; border: 2px solid var(--warning); padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-weight: 600; }

/* ===== RADIO BUTTONS ===== */
.radio-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    background: var(--bg-card);
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.95rem;
    position: relative;
    color: var(--text-primary);
    min-height: 44px;
}
.radio-option:hover:not(.selected) {
    border-color: var(--primary-blue);
    background: rgba(30, 58, 138, 0.05);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.radio-option.selected {
    border-color: var(--primary-blue);
    background: var(--primary-blue);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    font-weight: 600;
}
.radio-option:nth-child(1).selected { background: var(--success); border-color: var(--success); }
.radio-option:nth-child(2).selected { background: var(--danger); border-color: var(--danger); }
.radio-option:nth-child(2).selected.recommendation { background: var(--warning); border-color: var(--warning); }
.radio-option:nth-child(3).selected { background: var(--text-secondary); border-color: var(--text-secondary); }
.radio-option.action-option.selected,
.radio-option:nth-child(1).action-option.selected,
.radio-option:nth-child(2).action-option.selected {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: var(--white);
}

.radio-group {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    margin-top: 0.5rem;
}
.radio-group > .radio-option:nth-child(3) { grid-column: 1 / -1; grid-row: 2; padding: 0.5rem 1rem; font-size: 0.9rem; }
.radio-group:has(.radio-option:nth-child(4)) { display: flex; flex-direction: column; }
.radio-group:has(.radio-option:nth-child(4)) .radio-option { width: 100%; }
.radio-group.simple-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.radio-group.pass-fail { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.radio-group.descriptive { display: flex; flex-direction: column; }
.radio-group.descriptive .radio-option { text-align: left; padding: 1rem 1.5rem; width: 100%; }

/* ===== ACCESSIBILITY ===== */
.radio-option:focus { outline: 3px solid rgba(30, 58, 138, 0.3); outline-offset: 2px; }

@media (prefers-contrast: high) {
    .radio-option { border-width: 3px; }
    .radio-option.selected { border-width: 4px; font-weight: bold; }
}

/* ===== UTILITY CLASSES ===== */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap-gap { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.gap-sm { gap: var(--space-2); }
.gap-md { gap: var(--space-4); }

.page-header { background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%); color: var(--white); padding: var(--space-6); border-radius: var(--radius-md); margin-bottom: var(--space-6); }
.page-title { margin: 0; font-size: var(--text-2xl); color: var(--white); }
.page-subtitle { margin: var(--space-2) 0 0 0; opacity: 0.9; font-size: var(--text-sm); }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); }
.toolbar { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.content.no-padding { padding: 0; margin: 0; }

.text-muted { color: var(--text-secondary); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }

/* Breadcrumbs */
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-4); flex-wrap: wrap; padding: var(--space-3) 0; }
.breadcrumb a { color: var(--primary-blue); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .separator { color: var(--text-muted); }
.breadcrumb .current { color: var(--text-primary); font-weight: 500; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .btn { padding: 1rem; font-size: var(--text-base); }
    .navigation-buttons { padding: var(--space-3); }
    .radio-group { gap: 0.4rem; }
    .radio-option { padding: 0.5rem 0.75rem; font-size: var(--text-sm); min-height: 40px; }
    .radio-group > .radio-option:nth-child(3) { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
    .radio-group:has(.radio-option:nth-child(5)) { display: flex; flex-direction: column; }
}

/* ===== ANIMATIONS ===== */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes failPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .header, .nav-tabs, .navigation-buttons, .flash-messages, .flash-message { display: none !important; }
    .btn { display: none !important; }
    .radio-option.selected { border: 3px solid #000 !important; background: #000 !important; color: #fff !important; font-weight: bold; }
    .radio-option:not(.selected) { border: 2px solid #000; background: #fff; color: #000; }
    .status-fail, .pressure-reading-fail { border: 3px solid #000 !important; background: none !important; font-weight: bold !important; }
    body { padding-bottom: 0 !important; }
}
