/* ============================================
   SPFI LOAN SYSTEM - MOBILE-FIRST STYLES
   Blue/Green Theme - Optimized for Mobile
   ============================================ */

/* CSS Variables for Blue/Green Theme */
:root {
    --primary-blue: #1e88e5;
    --primary-green: #00c853;
    --dark-blue: #0d47a1;
    --dark-green: #00695c;
    --light-blue: #bbdefb;
    --light-green: #c8e6c9;
    --gradient-primary: linear-gradient(135deg, #1e88e5 0%, #00c853 100%);
    --gradient-dark: linear-gradient(135deg, #0d47a1 0%, #00695c 100%);
    --text-dark: #212121;
    --text-light: #757575;
    --bg-light: #f5f7fa;
    --white: #ffffff;
    --error: #d32f2f;
    --warning: #f57c00;
    --success: #00c853;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.2);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
}

/* Screen Management */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* ============================================
   LOGIN SCREEN - Mobile First
   ============================================ */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--gradient-primary);
    padding: 16px;
}

.login-box {
    background: var(--white);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-box h1 {
    text-align: center;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    font-size: 24px;
    font-weight: 700;
}

.login-box h2 {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 24px;
}

.login-tabs {
    display: flex;
    margin-bottom: 24px;
    background: var(--bg-light);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.tab-button {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    transition: var(--transition);
    min-height: 44px; /* Touch target */
}

.tab-button.active {
    background: var(--white);
    color: var(--primary-blue);
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: var(--transition);
    min-height: 44px; /* Touch target */
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 48px; /* Larger touch target for primary actions */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover,
.btn-primary:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-dark);
    border: 2px solid #e0e0e0;
}

.btn-danger {
    background: var(--error);
    color: var(--white);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

/* ============================================
   DASHBOARD LAYOUT - Mobile First
   ============================================ */

.dashboard-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Mobile Navigation Bar */
.navbar {
    background: var(--gradient-primary);
    color: var(--white);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 16px;
    font-weight: 700;
}

.navbar-user {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    min-height: 36px;
    transition: var(--transition);
}

.logout-btn:hover,
.logout-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile Sidebar - Hidden by default, toggleable */
.sidebar {
    background: var(--white);
    width: 100%;
    box-shadow: var(--shadow-md);
    padding: 16px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-dark);
    text-decoration: none;
    transition: var(--transition);
    font-size: 15px;
    border-left: 3px solid transparent;
    min-height: 48px; /* Touch target */
    cursor: pointer;
}

.sidebar-link:hover,
.sidebar-link:active {
    background: var(--light-blue);
    border-left-color: var(--primary-blue);
}

.sidebar-link.active {
    background: var(--light-blue);
    color: var(--primary-blue);
    border-left-color: var(--primary-blue);
    font-weight: 600;
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 16px;
    overflow-x: hidden;
}

.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-section h2 {
    font-size: 22px;
    color: var(--text-dark);
    margin-bottom: 16px;
    font-weight: 700;
}

/* ============================================
   CARDS - Mobile Optimized
   ============================================ */

.summary-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
    width: 100%;
}

.card {
    background: var(--white);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.card:active {
    transform: scale(0.98);
}

.card h3 {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card .value {
    font-size: 28px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card.blue {
    border-left: 4px solid var(--primary-blue);
}

.card.green {
    border-left: 4px solid var(--primary-green);
}

.card.warning {
    border-left: 4px solid var(--warning);
}

/* Card with icon styling */
.card-icon {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
}

.card-content h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.card-content p {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
}

/* ============================================
   TABLES - Mobile Responsive
   ============================================ */

.table-container {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Allow horizontal scroll on mobile */
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-dark);
    position: sticky;
    top: 0;
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: var(--light-blue);
}

/* Mobile-friendly table alternative - Card List */
.card-list {
    display: none; /* Show on mobile with media query */
}

.card-list-item {
    background: var(--white);
    padding: 16px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
}

.card-list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-list-item-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-dark);
}

.card-list-item-body {
    display: grid;
    gap: 8px;
}

.card-list-item-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.card-list-item-label {
    color: var(--text-light);
    font-weight: 500;
}

.card-list-item-value {
    color: var(--text-dark);
    font-weight: 600;
}

/* ============================================
   FORMS - Mobile Optimized
   ============================================ */

.form-container {
    background: var(--white);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-section {
    margin-bottom: 24px;
}

.form-section h3 {
    font-size: 18px;
    color: var(--text-dark);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--light-blue);
}

.text-muted {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 12px;
}

/* File Upload Styling */
input[type="file"] {
    padding: 8px !important;
    border: 2px dashed var(--primary-blue) !important;
    background: var(--light-blue);
    cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
    background: var(--primary-blue);
    color: var(--white);
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 12px;
    font-weight: 500;
}

/* ============================================
   BADGES & STATUS
   ============================================ */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.success {
    background: var(--light-green);
    color: var(--dark-green);
}

.badge.warning {
    background: #fff3e0;
    color: var(--warning);
}

.badge.error {
    background: #ffebee;
    color: var(--error);
}

.badge.info {
    background: var(--light-blue);
    color: var(--dark-blue);
}

/* ============================================
   MESSAGES & ALERTS
   ============================================ */

.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message.success {
    background: var(--light-green);
    color: var(--dark-green);
    border-left: 4px solid var(--success);
}

.message.error {
    background: #ffebee;
    color: var(--error);
    border-left: 4px solid var(--error);
}

.message.warning {
    background: #fff3e0;
    color: var(--warning);
    border-left: 4px solid var(--warning);
}

.message.info {
    background: var(--light-blue);
    color: var(--dark-blue);
    border-left: 4px solid var(--primary-blue);
}

/* Notification Items */
.notification-item {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.notification-item.alert {
    background: #ffebee;
    color: var(--error);
}

.notification-item.warning {
    background: #fff3e0;
    color: var(--warning);
}

/* ============================================
   ACTION BUTTONS IN TABLES
   ============================================ */

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    min-height: 36px;
    white-space: nowrap;
}

.action-btn.approve {
    background: var(--success);
    color: var(--white);
}

.action-btn.reject {
    background: var(--error);
    color: var(--white);
}

.action-btn.view {
    background: var(--primary-blue);
    color: var(--white);
}

.action-btn.edit {
    background: var(--warning);
    color: var(--white);
}

.action-btn:active {
    transform: scale(0.95);
}

/* ============================================
   PROFILE SECTION
   ============================================ */

.profile-info {
    margin-bottom: 24px;
}

.profile-info h3 {
    font-size: 20px;
    color: var(--text-dark);
    margin-bottom: 8px;
}

/* ============================================
   TABLET STYLES (600px and up)
   ============================================ */

@media (min-width: 600px) {
    .login-box {
        padding: 40px;
    }

    .login-box h1 {
        font-size: 32px;
    }

    .login-box h2 {
        font-size: 16px;
    }

    .navbar-brand {
        font-size: 18px;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-container {
        padding: 30px;
    }

    .main-content {
        padding: 24px;
    }

    .dashboard-section h2 {
        font-size: 26px;
    }
}

/* ============================================
   DESKTOP STYLES (1024px and up)
   ============================================ */

@media (min-width: 1024px) {
    .dashboard-container {
        flex-direction: row;
    }

    .sidebar {
        width: 280px;
        min-height: calc(100vh - 60px);
        padding: 24px 0;
    }

    .main-content {
        padding: 32px;
    }

    .summary-cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }

    .card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-md);
    }

    .card .value {
        font-size: 32px;
    }

    table th,
    table td {
        padding: 16px;
    }

    .form-container {
        padding: 40px;
    }

    .navbar-brand {
        font-size: 20px;
    }

    .dashboard-section h2 {
        font-size: 28px;
        margin-bottom: 24px;
    }
}

/* ============================================
   LARGE DESKTOP (1440px and up)
   ============================================ */

@media (min-width: 1440px) {
    .main-content {
        max-width: 1400px;
        margin: 0 auto;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .navbar,
    .sidebar,
    .btn,
    .action-buttons {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .dashboard-section.active {
        display: block !important;
    }

    body {
        background: var(--white);
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        border: 2px solid var(--white);
    }

    .sidebar-link.active {
        border-left-width: 5px;
    }
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.p-1 {
    padding: 8px;
}

.p-2 {
    padding: 16px;
}

.p-3 {
    padding: 24px;
}

.d-none {
    display: none;
}

.d-block {
    display: block;
}

.flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.gap-1 {
    gap: 8px;
}

.gap-2 {
    gap: 16px;
}

.gap-3 {
    gap: 24px;
}

/* ============================================
   MODAL STYLES
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--white);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease-out;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 22px;
}

.modal-content .close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-content .close:hover {
    color: var(--error);
    background: var(--bg-light);
}

/* ============================================
   FINANCIAL REPORT STYLES
   ============================================ */

.report-display {
    background: var(--white);
    padding: 32px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-top: 24px;
}

.report-header {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 3px solid var(--primary-blue);
}

.report-header h3 {
    font-size: 24px;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.report-subtitle {
    font-size: 18px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.report-period,
.report-generated {
    font-size: 14px;
    color: var(--text-light);
    margin: 4px 0;
}

.report-content {
    margin: 24px 0;
}

.report-title {
    font-size: 22px;
    color: var(--primary-blue);
    margin-bottom: 16px;
    text-align: center;
    font-weight: 700;
}

.financial-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.financial-table thead th {
    background: var(--light-blue);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border: 1px solid #e0e0e0;
}

.financial-table tbody td {
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
}

.financial-table .amount {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.financial-table .total-row {
    background: var(--bg-light);
    font-weight: 600;
}

.financial-table .highlight-row {
    background: var(--light-blue);
    font-weight: 700;
    font-size: 16px;
}

.financial-table .highlight-row.positive {
    background: var(--light-green);
    color: var(--dark-green);
}

.financial-table .highlight-row.negative {
    background: #ffebee;
    color: var(--error);
}

.financial-table .negative {
    color: var(--error);
}

.report-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 2px solid #e0e0e0;
}

.signature-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    margin-top: 48px;
}

.signature-box {
    text-align: center;
}

.signature-box p {
    margin: 8px 0;
}

.signature-box p:first-child {
    border-top: 2px solid var(--text-dark);
    padding-top: 4px;
    margin-top: 40px;
}

/* ============================================
   SETTINGS STYLES
   ============================================ */

.settings-container {
    background: var(--white);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.settings-item {
    margin-bottom: 24px;
    padding: 20px;
    border: 2px solid var(--light-blue);
    border-radius: 8px;
}

.settings-item h4 {
    color: var(--primary-blue);
    margin-bottom: 16px;
}

.settings-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

/* ============================================
   CHART & VISUALIZATION
   ============================================ */

.chart-placeholder {
    background: var(--white);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    min-height: 300px;
}

.portfolio-section,
.chart-section {
    background: var(--white);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.portfolio-stats {
    display: grid;
    gap: 16px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
}

.stat-label {
    font-weight: 600;
    color: var(--text-dark);
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-bar {
    flex: 1;
    height: 12px;
    background: var(--bg-light);
    border-radius: 6px;
    overflow: hidden;
    margin: 0 12px;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 6px;
    transition: width 0.5s ease;
}

/* ============================================
   BUTTON SIZES & VARIANTS
   ============================================ */

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    min-height: 32px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 18px;
    min-height: 56px;
}

/* ============================================
   TABLET RESPONSIVE UPDATES
   ============================================ */

@media (min-width: 600px) {
    .modal-content {
        width: 80%;
        padding: 32px;
    }
    
    .signature-section {
        gap: 64px;
    }
    
    .settings-form {
        gap: 16px;
    }
}

/* ============================================
   DESKTOP RESPONSIVE UPDATES
   ============================================ */

@media (min-width: 1024px) {
    .modal-content {
        width: 500px;
    }
    
    .report-display {
        padding: 48px;
    }
    
    .chart-placeholder {
        min-height: 400px;
    }
}

/* ============================================
   PRINT STYLES FOR REPORTS
   ============================================ */

@media print {
    body {
        background: white;
    }
    
    .navbar,
    .sidebar,
    .btn,
    .action-buttons,
    #printReportBtn,
    #exportPDFBtn,
    .form-container:first-child {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
        width: 100%;
    }
    
    .report-display {
        box-shadow: none;
        padding: 0;
    }
    
    .dashboard-section {
        display: block !important;
    }
    
    .financial-table {
        page-break-inside: avoid;
    }
    
    .signature-section {
        page-break-before: auto;
        margin-top: 100px;
    }
    
    @page {
        margin: 2cm;
    }
}

/* ============================================
   FINANCIAL REPORTS STYLING
   ============================================ */

.report-display {
    background: var(--white);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-top: 24px;
}

.report-header {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--primary-blue);
}

.report-header h3 {
    font-size: 24px;
    color: var(--primary-blue);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.report-subtitle {
    font-size: 18px;
    color: var(--text-light);
    margin: 8px 0;
}

.report-period,
.report-generated {
    font-size: 14px;
    color: var(--text-light);
    margin: 4px 0;
}

.report-title {
    font-size: 22px;
    color: var(--primary-blue);
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.report-content {
    margin: 24px 0;
}

.financial-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    background: var(--white);
}

.financial-table thead tr th {
    background: var(--bg-light);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 2px solid var(--primary-blue);
}

.financial-table tbody tr td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.financial-table tbody tr:last-child td {
    border-bottom: none;
}

.financial-table .amount {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

.financial-table .total-row {
    background: var(--light-blue);
    font-weight: 600;
}

.financial-table .highlight-row {
    background: var(--light-green);
    font-size: 18px;
}

.financial-table .highlight-row.positive {
    background: var(--light-green);
    color: var(--dark-green);
}

.financial-table .highlight-row.negative {
    background: #ffebee;
    color: var(--error);
}

.financial-table .negative {
    color: var(--error);
}

.report-footer {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 2px solid #e0e0e0;
}

.signature-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
    margin-top: 40px;
}

.signature-box {
    text-align: center;
}

.signature-box p {
    margin: 8px 0;
}

.signature-box p:first-child {
    margin-top: 60px;
    border-top: 2px solid var(--text-dark);
    padding-top: 8px;
}

/* Print Styles for Reports */
@media print {
    body {
        background: white;
    }

    .navbar,
    .sidebar,
    .form-container,
    .action-buttons,
    #printReportBtn,
    #exportPDFBtn {
        display: none !important;
    }

    .report-display {
        padding: 0;
        box-shadow: none;
        border-radius: 0;
    }

    .financial-table {
        page-break-inside: avoid;
    }

    .report-header {
        page-break-after: avoid;
    }

    .signature-section {
        page-break-before: avoid;
    }

    @page {
        margin: 2cm;
    }
}

/* Mobile Responsive for Reports */
@media (max-width: 600px) {
    .report-display {
        padding: 20px;
    }

    .report-header h3 {
        font-size: 20px;
    }

    .report-title {
        font-size: 18px;
    }

    .financial-table {
        font-size: 13px;
    }

    .financial-table thead tr th,
    .financial-table tbody tr td {
        padding: 8px;
    }

    .signature-section {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}

/* ============================================
   ENHANCED MOBILE OPTIMIZATION
   ============================================ */

/* Mobile-first improvements for phones */
@media (max-width: 768px) {
    /* Increase base font size for better readability */
    body {
        font-size: 16px;
    }

    /* Make buttons larger and more touch-friendly */
    .btn {
        min-height: 48px;
        padding: 12px 20px;
        font-size: 16px;
        font-weight: 600;
    }

    /* Improve form inputs for mobile */
    input, select, textarea {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
        border-radius: 8px;
    }

    /* Make sidebar toggleable on mobile */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
        width: 280px;
        max-width: 80vw;
    }

    .sidebar.active {
        left: 0;
        box-shadow: 2px 0 24px rgba(0,0,0,0.3);
    }

    /* Improve sidebar links for touch */
    .sidebar-link {
        padding: 16px 20px;
        font-size: 15px;
        min-height: 52px;
        display: flex;
        align-items: center;
    }

    /* Add backdrop when menu is open */
    .sidebar.active::after {
        content: '';
        position: fixed;
        top: 0;
        left: 280px;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: -1;
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Add hamburger menu */
    .navbar {
        position: relative;
        padding: 12px 16px;
    }

    .navbar::before {
        content: '☰';
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 28px;
        font-weight: 300;
        cursor: pointer;
        z-index: 10;
        color: white;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        transition: background 0.2s ease;
    }

    .navbar::before:active {
        background: rgba(255,255,255,0.2);
    }

    .navbar-brand {
        margin-left: 40px;
        font-size: 16px;
    }

    /* Fix dashboard container for mobile */
    .dashboard-container {
        display: flex;
        flex-direction: column;
    }

    /* Make main content full width on mobile */
    .main-content {
        margin-left: 0 !important;
        padding: 16px;
        width: 100%;
        overflow-x: hidden;
    }

    /* Fix dashboard sections */
    .dashboard-section {
        width: 100%;
        padding: 16px 0;
    }

    /* Ensure cards don't overflow */
    .card,
    .summary-cards {
        max-width: 100%;
        width: 100%;
    }

    /* Stack form rows vertically */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group {
        margin-bottom: 16px;
    }

    /* Make tables scrollable horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    .data-table {
        min-width: 600px;
        font-size: 14px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    /* Make cards stack better */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .stat-card {
        padding: 20px;
    }

    /* Better modal on mobile */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 5% auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Improve dashboard cards */
    .dashboard-section {
        padding: 16px;
    }

    h2 {
        font-size: 22px;
        margin-bottom: 16px;
    }

    h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    /* Better action buttons in tables */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-start;
    }

    .action-buttons .btn {
        flex: 0 1 auto;
        min-width: 80px;
        padding: 10px 14px;
        font-size: 13px;
        min-height: 42px;
        white-space: nowrap;
    }

    /* Single button takes more space */
    .action-buttons .btn:only-child {
        flex: 1;
        min-width: 100px;
    }

    /* Improve login screen */
    .login-container {
        width: 95%;
        max-width: 400px;
        padding: 24px;
    }

    .login-container h1 {
        font-size: 28px;
    }

    .login-container h2 {
        font-size: 20px;
    }

    /* Better spacing for lists */
    .loan-item,
    .transaction-item {
        padding: 16px;
        margin-bottom: 12px;
    }

    /* Make search inputs full width */
    input[type="search"],
    input[type="text"][placeholder*="Search"],
    input[type="text"][placeholder*="search"],
    input[type="text"][placeholder*="🔍"] {
        width: 100%;
        max-width: 100%;
        font-size: 15px;
        padding: 12px 16px;
        border-radius: 8px;
        border: 2px solid #e0e0e0;
    }

    input[type="search"]:focus,
    input[type="text"]:focus {
        border-color: var(--primary-blue);
        outline: none;
    }

    /* Better alerts */
    .alert {
        padding: 16px;
        font-size: 15px;
        border-radius: 8px;
    }

    /* Improve pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .pagination button {
        min-width: 44px;
        min-height: 44px;
    }

    /* Manager Dashboard Mobile Improvements */
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        padding: 16px;
    }

    .card-icon {
        font-size: 32px;
        margin-bottom: 8px;
    }

    .card-content h3 {
        font-size: 24px;
        margin-bottom: 4px;
    }

    .card-content p {
        font-size: 13px;
    }

    /* Portfolio section mobile */
    .portfolio-section {
        margin: 20px 0;
        padding: 16px;
    }

    .portfolio-stats {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .stat-item {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .stat-label {
        font-size: 13px;
        font-weight: 600;
        color: #666;
    }

    .stat-value {
        font-size: 20px;
        font-weight: 700;
        color: #1e88e5;
    }

    /* Chart section mobile */
    .chart-section {
        margin: 20px 0;
        padding: 16px;
    }

    .chart-placeholder {
        height: 250px;
        min-height: 250px;
    }

    /* Financial oversight cards */
    .financial-card {
        margin-bottom: 16px;
        padding: 16px;
    }

    .financial-card h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    /* Better table layout for approvals */
    .data-table th:nth-child(3),
    .data-table td:nth-child(3) {
        min-width: 120px;
    }

    .data-table th:nth-child(4),
    .data-table td:nth-child(4) {
        min-width: 120px;
    }

    /* Progress bars on mobile */
    .progress-bar {
        height: 12px;
        border-radius: 6px;
        overflow: hidden;
        background: #e0e0e0;
    }

    .progress-fill {
        height: 100%;
        background: linear-gradient(90deg, #1e88e5 0%, #00c853 100%);
        transition: width 0.5s ease;
    }
}

/* Extra small phones (320px - 480px) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .navbar-brand {
        font-size: 14px;
    }

    .btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 15px;
    }

    .stat-card h3 {
        font-size: 14px;
    }

    .stat-card .stat-value {
        font-size: 24px;
    }

    .modal-content {
        width: 98%;
        padding: 16px;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
    }

    /* Single column for small phones */
    .summary-cards {
        grid-template-columns: 1fr;
    }
}

/* Medium phones - 2 column grid for summary cards */
@media (min-width: 481px) and (max-width: 768px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* Modern smartphones optimization (iPhone 15, Pixel 5, etc. ~390-430px) */
@media (min-width: 375px) and (max-width: 430px) {
    /* Slightly larger base font */
    body {
        font-size: 15px;
    }

    /* Better navbar spacing */
    .navbar {
        padding: 14px 18px;
    }

    .navbar-brand {
        margin-left: 45px;
        font-size: 17px;
        font-weight: 600;
    }

    /* Optimize cards for this size */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        margin-bottom: 20px;
    }

    .card {
        padding: 18px;
    }

    .card-icon {
        font-size: 36px;
        margin-bottom: 10px;
    }

    .card-content h3 {
        font-size: 28px;
        font-weight: 700;
    }

    .card-content p {
        font-size: 12px;
        letter-spacing: 0.3px;
    }

    /* Better spacing for main content */
    .main-content {
        padding: 18px;
    }

    .dashboard-section h2 {
        font-size: 24px;
        margin-bottom: 18px;
    }

    .dashboard-section h3 {
        font-size: 19px;
        margin-bottom: 14px;
    }

    /* Portfolio section optimization */
    .portfolio-section {
        padding: 18px;
        margin: 18px 0;
    }

    .stat-value {
        font-size: 22px;
    }

    /* Better button sizing */
    .btn {
        min-height: 46px;
        padding: 11px 18px;
        font-size: 15px;
    }

    /* Input fields */
    input, select, textarea {
        min-height: 46px;
        font-size: 15px;
        padding: 11px 14px;
    }

    /* Table improvements */
    .table-container {
        margin: 0 -18px;
        padding: 0 18px;
    }

    .data-table {
        font-size: 13px;
    }

    /* Modal adjustments */
    .modal-content {
        width: 92%;
        padding: 20px;
    }

    /* Chart sizing */
    .chart-placeholder {
        height: 280px;
        min-height: 280px;
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 85vh;
        margin: 2% auto;
    }

    .sidebar {
        width: 240px;
        left: -240px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase click targets */
    a, button, .btn, input[type="submit"], input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .sidebar-link:hover {
        transform: none;
    }

    /* Add active states instead */
    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .sidebar-link:active {
        background: rgba(255,255,255,0.15);
    }

    /* Improve table row tap targets */
    .data-table tr {
        min-height: 48px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix iOS input zoom */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Fix iOS sticky elements */
    .navbar {
        position: -webkit-sticky;
        position: sticky;
    }

    /* Fix iOS overflow scrolling */
    .table-container,
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    body {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    .card {
        background: #2a2a2a;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }

    input, select, textarea {
        background: #333;
        color: #e0e0e0;
        border-color: #555;
    }

    .sidebar {
        background: linear-gradient(135deg, #1a237e 0%, #004d40 100%);
    }

    .data-table {
        background: #2a2a2a;
    }

    .data-table th {
        background: #1a1a1a;
    }

    .data-table tr:nth-child(even) {
        background: #242424;
    }
}
