:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --secondary: #0ea5e9;
    --accent: #10b981;
    --bg-main: #f0fdf4;
    --bg-gradient: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    --surface: rgba(255, 255, 255, 0.7);
    --surface-solid: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.5);
    --border-dark: #e2e8f0;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    --glass-blur: blur(12px);
    
    --a4-width: 210mm;
    --a4-height: 297mm;
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    border-radius: 20px;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-lg);
    border-radius: 24px;
}

/* Layouts */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.center-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Typography */
.text-gradient {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-4 { margin-top: 2rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary);
    border: 1px solid var(--primary-light);
}
.btn-secondary:hover {
    background: white;
    transform: translateY(-2px);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-dark);
    background: rgba(255, 255, 255, 0.8);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1rem;
    transition: all 0.2s ease;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    background: #ffffff;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/200.svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
}

/* Login Screen */
.login-card {
    width: 100%;
    max-width: 420px;
    padding: 3rem 2.5rem;
}

/* Dashboard */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}
.user-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 3fr;
    gap: 2rem;
}

.card {
    padding: 1.5rem;
}

.menu-list {
    list-style: none;
}
.menu-item {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
}
.menu-item:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--primary);
}
.menu-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.report-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.report-card {
    padding: 1.5rem;
    border-radius: 16px;
    background: white;
    border: 1px solid var(--border-dark);
    transition: all 0.3s ease;
    cursor: pointer;
}
.report-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.report-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.report-badge {
    background: #e0f2fe;
    color: var(--primary-dark);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.report-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.dynamic-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .dynamic-form-grid { grid-template-columns: 1fr; }
}

/* A4 Print Report Preview */
.report-preview-container {
    background: #cbd5e1;
    padding: 2rem;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    overflow-x: auto;
}
.a4-paper {
    width: var(--a4-width);
    min-height: var(--a4-height);
    background: white;
    box-shadow: var(--shadow-lg);
    padding: 20mm 15mm;
    position: relative;
    color: black;
    font-family: 'Times New Roman', serif;
}

.letterhead {
    text-align: center;
    border-bottom: 2px solid #2563eb;
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.letterhead h1 {
    font-family: 'Arial', sans-serif;
    color: #2563eb;
    font-size: 24px;
    margin-bottom: 5px;
}
.letterhead p {
    font-size: 14px;
    color: #475569;
    font-family: 'Arial', sans-serif;
}

.patient-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    font-size: 15px;
    font-family: 'Arial', sans-serif;
    background: #f8fafc;
    padding: 10px 15px;
    border-radius: 4px;
}

.test-title {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 20px;
    text-decoration: underline;
    font-family: 'Arial', sans-serif;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}
.results-table th, .results-table td {
    border: 1px solid #cbd5e1;
    padding: 8px 12px;
    text-align: left;
}
.results-table th {
    background: #f1f5f9;
    font-weight: bold;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
}
.results-table td {
    font-size: 14px;
}
.out-of-range {
    color: #dc2626;
    font-weight: bold;
}

.signature-block {
    margin-top: 50px;
    display: flex;
    justify-content: flex-end;
}
.signature-line {
    border-top: 1px solid black;
    width: 250px;
    text-align: center;
    padding-top: 5px;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
}

.action-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.letterhead {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-bottom: 2px solid #2563eb;
    padding-bottom: 10px;
    margin-bottom: 20px;
    text-align: center;
}
.letterhead-logo {
    max-height: 80px;
    width: auto;
}
.letterhead-text h1 {
    font-family: 'Arial', sans-serif;
    color: #2563eb;
    font-size: 24px;
    margin-bottom: 5px;
}
.letterhead-text p {
    font-size: 14px;
    color: #475569;
    font-family: 'Arial', sans-serif;
    margin: 0;
}

/* Analytics & Billing */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-dark);
    box-shadow: var(--shadow-sm);
    text-align: center;
}
.stat-card h3 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}
.stat-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: uppercase;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.invoice-table th, .invoice-table td {
    border-bottom: 1px solid var(--border-dark);
    padding: 1rem;
    text-align: left;
}
.invoice-table th {
    background: rgba(255,255,255,0.5);
    color: var(--text-muted);
    font-weight: 600;
}
.badge-unpaid {
    background: #fee2e2; color: #dc2626;
    padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: bold;
}
.badge-paid {
    background: #dcfce3; color: #16a34a;
    padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: bold;
}

/* Invoice Print Styles */
.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}
.invoice-details h2 {
    color: #2563eb;
    margin-bottom: 5px;
    font-size: 28px;
    text-transform: uppercase;
}
.invoice-totals {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
}
.invoice-totals table {
    width: 300px;
    border-collapse: collapse;
}
.invoice-totals th, .invoice-totals td {
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
}
.invoice-totals .grand-total {
    font-weight: bold;
    font-size: 18px;
    color: #0f172a;
}
.paid-stamp {
    color: #dc2626;
    border: 4px solid #dc2626;
    display: inline-block;
    padding: 10px 20px;
    font-size: 24px;
    font-weight: bold;
    text-transform: uppercase;
    transform: rotate(-15deg);
    opacity: 0.7;
    margin-top: 20px;
    position: absolute;
    right: 50px;
    top: 250px;
}

/* Split Screen Login Design */
.login-page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #0f172a; /* Navy blue base */
    font-family: 'Arial', sans-serif;
    color: white;
}
.login-topbar {
    background-color: #1e293b; /* Dark slate */
    border-bottom: 1px solid #334155;
    color: #e2e8f0;
    padding: 10px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}
.login-topbar-left {
    display: flex;
    gap: 30px;
}
.login-topbar-left span {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
}
.login-topbar-right {
    display: flex;
    gap: 10px;
}
.topbar-btn {
    background: #334155;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
}
.topbar-btn:hover {
    background: #475569;
}
.topbar-btn-green {
    background: #2563eb; /* Medical Blue */
    color: white;
    font-weight: bold;
}
.topbar-btn-green:hover {
    background: #1d4ed8;
}
.login-split-container {
    display: flex;
    flex: 1;
}
.login-left {
    flex: 1;
    background-color: #1e293b; /* Lighter navy */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    position: relative;
    /* faint grid background effect */
    background-image: linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 40px 40px;
}
.login-left-logo {
    max-width: 140px;
    margin-bottom: 20px;
    filter: drop-shadow(0px 4px 6px rgba(0,0,0,0.3));
}
.login-left-subtitle {
    color: #38bdf8; /* Light blue accent */
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 10px;
}
.login-left h1 {
    font-size: 42px;
    margin-bottom: 20px;
    font-weight: 800;
}
.login-left p {
    font-size: 16px;
    color: #cbd5e1;
    max-width: 400px;
    line-height: 1.5;
}
.login-right {
    flex: 1;
    background-color: #0f172a; /* Dark navy */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.login-form-container {
    width: 100%;
    max-width: 400px;
}
.login-form-container h2 {
    font-size: 28px;
    margin-bottom: 5px;
}
.login-form-container p {
    color: #94a3b8;
    font-size: 14px;
    margin-bottom: 30px;
}
.login-form-container .form-group {
    margin-bottom: 20px;
}
.login-form-container .form-label {
    color: #e2e8f0;
    font-size: 13px;
    margin-bottom: 8px;
}
.login-form-container .form-control {
    background: white;
    border: 1px solid #334155;
    padding: 14px;
    border-radius: 6px;
    color: #0f172a;
    width: 100%;
}
.login-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin-bottom: 25px;
}
.login-options a {
    color: #38bdf8;
    text-decoration: none;
}
.login-btn-submit {
    background-color: #2563eb; /* Medical blue */
    color: white;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}
.login-btn-submit:hover {
    background-color: #1d4ed8;
}
.login-footer-links {
    text-align: center;
    font-size: 14px;
    color: #cbd5e1;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 20px;
}
.login-footer-links a {
    color: #38bdf8;
    text-decoration: none;
    font-weight: bold;
}

/* =========================================
   Mobile Responsiveness (Max Width: 768px)
   ========================================= */
@media (max-width: 768px) {
    /* Login Page */
    .login-topbar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 10px;
    }
    .login-topbar-left {
        flex-direction: column;
        gap: 5px;
    }
    .login-topbar-right {
        flex-wrap: wrap;
        justify-content: center;
    }
    .login-split-container {
        flex-direction: column;
    }
    .login-left, .login-right {
        padding: 20px;
    }
    
    /* Dashboard & General Layout */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    .user-profile {
        justify-content: center;
    }
    .glass-panel {
        padding: 1rem !important;
    }
    
    /* Tables */
    .invoice-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* A4 Paper Preview */
    .report-preview-container {
        overflow-x: auto;
        padding-bottom: 20px;
    }
    .a4-paper {
        margin: 0 auto;
        /* Keep it 210mm to preserve PDF layout, allow horizontal scrolling */
    }
    
    /* Action Bar */
    .action-bar {
        flex-direction: column;
        gap: 10px;
    }
    .action-bar > div {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    .action-bar button {
        width: 100%;
    }
    
    /* Dynamic Form Grid */
    .dynamic-form-grid {
        grid-template-columns: 1fr;
    }
}
