/* Modern CSS Variables - Matching design_temp teal/cyan theme */
:root {
    /* Primary teal/cyan colors */
    --primary: #14b8a6;
    --primary-dark: #0d9488;
    --primary-light: #5eead4;
    --primary-foreground: #ffffff;
    
    /* Secondary colors */
    --secondary: #e0f2fe;
    --secondary-foreground: #0c4a6e;
    
    /* Accent */
    --accent: #2dd4bf;
    --accent-foreground: #ffffff;
    
    /* Background */
    --background: #fafafa;
    --foreground: #0f172a;
    
    /* Card */
    --card: #ffffff;
    --card-foreground: #0f172a;
    
    /* Muted */
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    
    /* Border & Input */
    --border: #e2e8f0;
    --input: #e2e8f0;
    --ring: #14b8a6;
    
    /* Status colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Shadows - minimal like design_temp */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-xs: 0 1px 1px 0 rgba(0, 0, 0, 0.03);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    
    /* Border radius */
    --radius: 0.75rem;
    --radius-lg: 1rem;
    --radius-md: 0.625rem;
    --radius-sm: 0.5rem;
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    min-height: 100vh;
    color: var(--foreground);
    line-height: 1.6;
    /* Prevent text size adjustment on iOS */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Better scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

/* Header - Matching design_temp */
.header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Desktop only: Make header always fixed at top */
@media (min-width: 769px) {
    .header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 200 !important;
        width: 100% !important;
    }
    
    /* Main content will get padding-top via JavaScript to account for fixed header */
    .main-content {
        transition: padding-top 0.2s ease;
    }
}

/* Mobile: Keep header sticky but lower z-index */
@media (max-width: 768px) {
    .header {
        position: sticky;
        top: 0;
        z-index: 100;
    }
}

.header-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo > div:first-child {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: var(--primary-foreground);
    flex-shrink: 0;
}

.logo > div:first-child svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--primary-foreground);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0;
}

.header-subtitle {
    color: var(--muted-foreground);
    font-size: 0.75rem;
    margin-left: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Profile Menu */
.profile-menu-container {
    position: relative;
}

.profile-trigger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    outline: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.profile-trigger:focus-visible {
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

.profile-trigger:hover .profile-avatar {
    box-shadow: 0 0 0 2px var(--primary);
}

.profile-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    transition: var(--transition);
    border: 2px solid transparent;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 14rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.profile-dropdown-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.25rem;
}

.profile-dropdown-email {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.profile-dropdown-separator {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

.profile-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    text-align: left;
    color: var(--foreground);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.profile-dropdown-item:hover {
    background: var(--muted);
}

.profile-dropdown-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--muted-foreground);
}

.profile-dropdown-item:hover svg {
    color: var(--foreground);
}

.profile-dropdown-item-danger {
    color: var(--danger);
}

.profile-dropdown-item-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.profile-dropdown-item-danger svg {
    color: var(--danger);
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.back-btn:hover {
    background: var(--gray-200);
    transform: translateX(-4px);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Cards - Matching design_temp */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

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

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.card-header h2, .card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-header-icon-btn {
    padding: 0.25rem;
    min-width: auto;
    width: auto;
    border-radius: 999px;
    margin-left: 0.25rem;
}

.card-header .badge {
    margin-left: auto;
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    font-weight: 400;
}

.card-header svg {
    color: var(--primary);
}

.card-body {
    padding: 1.5rem;
}

/* Create Loan Section - Matching design_temp */
.create-loan-section {
    margin-bottom: 2rem;
}

.create-card {
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

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

.create-card .card-header {
    background: var(--muted);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
}

.create-card .card-header h2 {
    color: var(--foreground);
    font-weight: 600;
    font-size: 1.25rem;
}

.create-card .card-header h2 > svg:first-child {
    width: 2rem;
    height: 2rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: var(--primary-foreground);
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--foreground);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    cursor: help;
    transition: var(--transition);
}

.info-icon:hover {
    color: var(--primary);
}

.info-icon svg {
    width: 100%;
    height: 100%;
}

.info-icon[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    padding: 0.75rem 1rem;
    background: var(--gray-900);
    color: white;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-line;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 280px;
    max-width: 320px;
    pointer-events: none;
    animation: tooltipFadeIn 0.2s ease;
}

.info-icon[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 2px);
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--gray-900);
    z-index: 1001;
    pointer-events: none;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.form-group input, .form-group select {
    padding: 0.625rem 0.75rem;
    height: 2.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: var(--transition);
    background: transparent;
    color: var(--foreground);
    /* Better touch interactions */
    touch-action: manipulation;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* Party details (lender/borrower) below dropdown in promissory note modal */
.party-details {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--muted);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.party-details-content {
    flex: 1;
    min-width: 0;
}

.party-details-name {
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.25rem;
}

.party-details-meta {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin-bottom: 0.25rem;
}

.party-details-address {
    font-size: 0.8125rem;
    color: var(--foreground);
    white-space: pre-line;
    margin-bottom: 0.25rem;
}

.party-details-signer {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.payment-toggle {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    border-radius: 0;
    border: none;
    background: transparent;
    color: var(--foreground);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    /* Better touch interactions */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.radio-pill input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary);
    cursor: pointer;
    /* Better touch target */
    min-width: 1.25rem;
    min-height: 1.25rem;
}

.radio-pill:hover {
    color: var(--foreground);
}

.radio-pill input:checked + span {
    font-weight: 400;
    color: var(--foreground);
}

.radio-pill:has(input:checked) {
    border: none;
    background: transparent;
}

.form-hint {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.form-hint.warning {
    color: #f97316;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--gray-500);
    font-weight: 600;
    pointer-events: none;
}

.input-with-icon input {
    padding-left: 2.5rem;
}

.input-icon-right {
    position: absolute;
    right: 1rem;
    color: var(--gray-500);
    font-weight: 600;
    pointer-events: none;
}

.input-with-icon input:has(~ .input-icon-right) {
    padding-right: 3rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    outline: none;
    /* Better touch interactions */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: var(--shadow-xs);
}

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

.btn-secondary {
    background: var(--background);
    color: var(--foreground);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

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

.btn-danger-outline {
    background: white;
    color: var(--danger);
    border: 2px solid var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-large {
    padding: 0.625rem 2rem;
    height: 2.75rem;
    font-size: 1rem;
    font-weight: 500;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Loans Section */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--foreground);
    font-weight: 600;
}

.section-header p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

.loans-count {
    background: var(--secondary);
    color: var(--secondary-foreground);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.875rem;
}

.section-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-small svg {
    width: 16px;
    height: 16px;
}

.loans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.loan-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
    position: relative;
    cursor: default;
}

.loan-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

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

.loan-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 1rem;
    gap: 1rem;
}

.loan-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

.loan-card-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.loan-card-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.loan-card-meta-item svg {
    width: 0.75rem;
    height: 0.75rem;
}

.loan-card-menu-container {
    position: relative;
}

.loan-card-menu {
    background: none;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Better touch interactions */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.loan-card-menu:hover {
    background: var(--muted);
    color: var(--foreground);
}

.loan-card-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
    min-width: 150px;
    overflow: hidden;
    /* Better touch interactions */
    touch-action: manipulation;
}

.loan-card-menu-dropdown button {
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    text-align: left;
    color: var(--foreground);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Better touch interactions */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 2.75rem;
}

.loan-card-menu-dropdown button:hover {
    background: var(--muted);
}

.loan-card-menu-dropdown button:first-child {
    border-bottom: 1px solid var(--border);
}

.loan-card-principal {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0 0 1rem 1.5rem;
    line-height: 1;
}

.loan-card-stats {
    display: flex;
    align-items: stretch;
    gap: 1rem;
    padding: 0 1.5rem 1.25rem;
}

.loan-card-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    justify-content: space-between;
}

.loan-card-stat-label {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.2;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.loan-card-stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--foreground);
    line-height: 1.4;
    height: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.loan-card-stat-divider {
    width: 1px;
    background: var(--border);
    align-self: stretch;
}

.loan-card-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border);
}

.loan-card-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.loan-card-detail-label {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    font-weight: 400;
}

.loan-card-detail-value {
    font-size: 0.875rem;
    color: var(--foreground);
    font-weight: 600;
}

.loan-card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border);
}

.loan-card-btn-primary,
.loan-card-btn-secondary {
    flex: 1;
}

.loan-card-btn-secondary {
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--foreground);
}

.loan-card-btn-secondary:hover {
    background: var(--muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted-foreground);
}

.empty-state svg {
    margin: 0 auto 1rem;
    color: var(--muted-foreground);
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--foreground);
}

.empty-state p {
    color: var(--muted-foreground);
}

/* Loan Details Page */
.loan-details-page {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 0.875rem;
    font-weight: 600;
}

.stat-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Sticky Tabs Navbar (Desktop Only) */
.sticky-tabs-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    z-index: 190;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.sticky-tabs-navbar.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.sticky-tabs-navbar.visible {
    transform: translateY(0);
    opacity: 1;
}

.sticky-tabs-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
}

.sticky-tabs-navbar .tabs {
    margin: 0;
    box-shadow: none;
    border-radius: var(--radius-md);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    background: white;
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    transition: var(--transition);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
    transform: translateY(-1px);
}

.tab-btn svg {
    width: 20px;
    height: 20px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Forms in tabs */
.inline-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.inline-form .form-group {
    flex: 1;
    min-width: 200px;
}

/* Data List */
.data-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.data-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.data-item:hover {
    background: var(--gray-100);
}

.data-item-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.data-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.data-item-details {
    flex: 1;
}

.data-item-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.data-item-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.data-item-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--gray-400);
    transition: var(--transition);
    /* Better touch interactions */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
    background: var(--gray-200);
    color: var(--gray-600);
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Statement View */
.statement-view {
    font-family: 'Courier New', monospace;
    background: var(--gray-50);
    padding: 2rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    line-height: 1.8;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    transition: var(--transition);
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: var(--foreground);
    margin-bottom: 1rem;
}

.modal-warning {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    border-radius: var(--radius-sm);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-info .toast-icon {
    background: var(--info);
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

.toast-success .toast-icon {
    background: var(--success);
}

.toast-error .toast-icon {
    background: var(--danger);
}

.toast-message {
    flex: 1;
    font-weight: 500;
    color: var(--gray-900);
}

/* Responsive - Mobile Optimizations */
@media (max-width: 768px) {
    /* CRITICAL: Hide desktop summary cards on mobile - they should NEVER appear on mobile */
    /* The mobile-kpis inside kpis-tab will be the only KPIs shown on mobile */
    div#desktop-summary-cards,
    #desktop-summary-cards,
    .desktop-summary-cards,
    .summary-cards.desktop-summary-cards,
    main > #desktop-summary-cards,
    .main-content > #desktop-summary-cards,
    .loan-details-page > #desktop-summary-cards,
    .force-hide-mobile,
    #desktop-summary-cards.force-hide-mobile {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
        width: 0 !important;
        opacity: 0 !important;
        grid-template-columns: none !important;
        gap: 0 !important;
        pointer-events: none !important;
    }
    
    /* CRITICAL: On mobile, only show active tab content */
    /* This ensures KPIs only show in KPI tab, and are hidden in all other tabs */
    .loan-details-page .tab-content:not(.active) {
        display: none !important;
    }
    
    .loan-details-page .tab-content.active {
        display: block !important;
    }
    
    /* Ensure kpis-tab only shows when active */
    #kpis-tab:not(.active) {
        display: none !important;
    }
    
    #kpis-tab.active {
        display: block !important;
    }
    
    /* Ensure mobile-kpis are only visible when kpis-tab is active */
    #kpis-tab.active .mobile-kpis {
        display: grid !important;
    }
    
    #kpis-tab:not(.active) .mobile-kpis {
        display: none !important;
    }
    
    /* Header improvements */
    .header-subtitle {
        display: none;
    }
    
    .header-content {
        padding: 0.75rem 1rem;
    }
    
    .profile-avatar {
        width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }
    
    .profile-dropdown {
        min-width: 12rem;
        right: 0;
    }
    
    .profile-dropdown-item {
        padding: 0.875rem 1rem;
        min-height: 3rem;
        font-size: 0.9375rem;
    }
    
    .logo h1 {
        font-size: 1.125rem;
    }
    
    .logo > div:first-child {
        width: 2rem;
        height: 2rem;
    }
    
    /* Main content spacing */
    .main-content {
        padding: 1rem;
    }
    
    /* Card improvements */
    .card-header {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header h2, .card-header h3 {
        font-size: 1.125rem;
    }
    
    /* Form improvements */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .form-group input, 
    .form-group select {
        height: 3rem;
        font-size: 1rem; /* Prevents zoom on iOS */
        padding: 0.75rem 1rem;
    }
    
    .input-with-icon input {
        padding-left: 2.75rem;
    }
    
    .input-icon {
        left: 1rem;
        font-size: 1rem;
    }
    
    .input-icon-right {
        right: 1rem;
        font-size: 1rem;
    }
    
    /* Better touch targets for buttons */
    .btn {
        min-height: 3rem;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .btn-small {
        min-height: 2.75rem;
        padding: 0.625rem 1.25rem;
    }
    
    .btn-large {
        min-height: 3.25rem;
        padding: 0.875rem 2rem;
        font-size: 1.125rem;
    }
    
    /* Loans grid */
    .loans-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Loan card mobile optimizations */
    .loan-card {
        border-radius: var(--radius-md);
    }
    
    .loan-card-header {
        padding: 1rem 1rem 0.75rem;
    }
    
    .loan-card-title {
        font-size: 1rem;
    }
    
    .loan-card-meta {
        font-size: 0.7rem;
        gap: 0.75rem;
        flex-wrap: wrap;
    }
    
    .loan-card-principal {
        font-size: 1.75rem;
        margin: 0 0 0.75rem 1rem;
    }
    
    .loan-card-stats {
        flex-direction: row;
        gap: 0.75rem;
        padding: 0 1rem 1rem;
        flex-wrap: wrap;
    }
    
    .loan-card-stat {
        flex: 1;
        min-width: calc(50% - 0.375rem);
    }
    
    .loan-card-stat-label {
        font-size: 0.7rem;
        height: auto;
        margin-bottom: 0.25rem;
        text-align: center;
        justify-content: center;
    }
    
    .loan-card-stat-value {
        font-size: 0.9rem;
        height: auto;
        text-align: center;
        justify-content: center;
    }
    
    .loan-card-stat-divider {
        display: none;
    }
    
    .loan-card-details {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .loan-card-actions {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .loan-card-btn-primary,
    .loan-card-btn-secondary {
        width: 100%;
        min-height: 3rem;
    }
    
    /* Better dropdown menu on mobile */
    .loan-card-menu {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .loan-card-menu-dropdown {
        min-width: 180px;
        right: 0;
        left: auto;
    }
    
    .loan-card-menu-dropdown button {
        padding: 1rem 1.25rem;
        font-size: 0.9375rem;
        min-height: 3rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Action bar */
    .action-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .action-bar .btn {
        width: 100%;
    }
    
    /* Section header */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.25rem;
    }
    
    .section-header h2 {
        font-size: 1.25rem;
    }
    
    .section-header-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    /* Tabs - horizontal scroll on mobile */
    .tabs {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 2.75rem;
    }
    
    .tab-btn svg {
        width: 18px;
        height: 18px;
    }
    
    /* Inline forms */
    .inline-form {
        flex-direction: column;
        gap: 1rem;
    }
    
    .inline-form .form-group {
        min-width: 100%;
    }
    
    .inline-form .btn {
        width: 100%;
    }
    
    /* Modals - full screen on mobile */
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .modal-header {
        padding: 1.25rem 1rem;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-actions {
        flex-direction: column-reverse;
        gap: 0.75rem;
        margin-top: 1.25rem;
    }
    
    .modal-actions .btn {
        width: 100%;
    }
    
    /* Toast notifications */
    .toast-container {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
    
    /* Data list items */
    .data-item {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .data-item-content {
        width: 100%;
    }
    
    .data-item-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    /* Statement view */
    .statement-view {
        padding: 1rem;
        font-size: 0.8rem;
        overflow-x: auto;
    }
    
    /* Empty state */
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state h3 {
        font-size: 1.25rem;
    }
    
    /* Create loan section */
    .create-loan-section {
        margin-bottom: 1.5rem;
    }
    
    .create-card .card-header {
        padding: 1rem;
    }
    
    /* Payment toggle - better mobile layout */
    .payment-toggle {
        gap: 1rem;
    }
    
    .radio-pill {
        padding: 0.75rem;
        min-height: 3rem;
        font-size: 1rem;
    }
    
    .radio-pill input[type="radio"] {
        width: 1.5rem;
        height: 1.5rem;
        min-width: 1.5rem;
        min-height: 1.5rem;
    }
    
    /* Info icon tooltips - adjust for mobile */
    .info-icon[data-tooltip]:hover::after {
        min-width: 200px;
        max-width: calc(100vw - 2rem);
        left: 50%;
        transform: translateX(-50%);
    }
    
    /* Back button */
    .back-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
    
    /* Loan details page header */
    .loan-details-page .header-content {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .loan-details-page .logo {
        order: 2;
        flex: 1;
        min-width: 0;
    }
    
    .loan-details-page .back-btn {
        order: 1;
    }
    
    .loan-details-page #delete-loan-btn {
        order: 3;
        width: 100%;
        margin-top: 0.5rem;
    }
    
    /* Import summary */
    .import-summary {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    /* Form actions */
    .form-actions {
        margin-top: 1.25rem;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Additional mobile optimizations for very small screens */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
    }
    
    .card-header,
    .card-body {
        padding: 0.875rem;
    }
    
    .loan-card-header {
        padding: 0.875rem 0.875rem 0.625rem;
    }
    
    .loan-card-principal {
        font-size: 1.5rem;
        margin-left: 0.875rem;
    }
    
    .loan-card-stats {
        padding: 0 0.875rem 0.875rem;
    }
    
    .loan-card-actions {
        padding: 0.875rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .section-header h2 {
        font-size: 1.125rem;
    }
    
    .tab-btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    .modal-header h3 {
        font-size: 1.125rem;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Import Modal Styles */
.import-summary {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--muted);
    border-radius: var(--radius);
}

.import-stat {
    text-align: center;
}

.import-stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--foreground);
}

.import-stat-label {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

.import-detail-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.import-detail-section strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.import-detail-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.import-detail-section li {
    padding: 0.5rem;
    background: var(--muted);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--foreground);
}

/* Custom Confirmation Dialog */
.confirm-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.confirm-dialog.active {
    display: flex;
}

.confirm-dialog-content {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    animation: slideUp 0.3s ease;
    border: 1px solid var(--border);
}

.confirm-dialog-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.confirm-dialog-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--danger);
    color: white;
}

.confirm-dialog-icon.warning {
    background: var(--warning);
}

.confirm-dialog-icon.info {
    background: var(--info);
}

.confirm-dialog-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0;
    flex: 1;
}

.confirm-dialog-body {
    padding: 1.5rem;
}

.confirm-dialog-body p {
    color: var(--foreground);
    margin: 0;
    line-height: 1.6;
    font-size: 0.9375rem;
}

.confirm-dialog-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--muted);
}

.confirm-dialog-actions .btn {
    min-width: 100px;
}

/* Mobile optimizations for confirm dialog */
@media (max-width: 768px) {
    .confirm-dialog-content {
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin: 0;
        max-height: 90vh;
        animation: slideUpMobile 0.3s ease;
    }
    
    .confirm-dialog-header {
        padding: 1.25rem 1rem;
    }
    
    .confirm-dialog-body {
        padding: 1rem;
    }
    
    .confirm-dialog-actions {
        flex-direction: column-reverse;
        gap: 0.75rem;
        padding: 1rem;
    }
    
    .confirm-dialog-actions .btn {
        width: 100%;
    }
}

/* Utility Classes */
.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

/* Ensure desktop tabs are visible on desktop */
.tabs-desktop {
    display: flex;
}

/* Desktop: Add padding to body when sticky navbar is visible */
@media (min-width: 769px) {
    body.sticky-navbar-visible {
        padding-top: 0;
    }
    
    .sticky-tabs-navbar {
        display: block;
    }
}

/* Mobile: Hide sticky navbar */
@media (max-width: 768px) {
    .sticky-tabs-navbar {
        display: none !important;
    }
}

/* Hide mobile bottom tabs on desktop */
.mobile-bottom-tabs {
    display: none;
}

/* Hide mobile more menu on desktop */
.mobile-more-menu {
    display: none;
}

/* Loan Detail Page - Mobile Improvements */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: block !important;
    }
    
    /* Header Improvements */
    .loan-detail-header .header-content {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .mobile-back-btn {
        order: 1;
        padding: 0.5rem;
        min-width: auto;
    }
    
    .back-btn-text {
        display: none;
    }
    
    .loan-header-content {
        order: 2;
        flex: 1;
        min-width: 0;
    }
    
    .loan-header-title {
        font-size: 1.125rem;
        font-weight: 600;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .loan-header-subtitle {
        font-size: 0.75rem;
        color: var(--muted-foreground);
        margin: 0.25rem 0 0 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-actions {
        order: 3;
    }
    
    .delete-loan-btn {
        padding: 0.5rem 0.75rem;
        min-height: 2.5rem;
    }
    
    .delete-btn-text {
        display: none;
    }
    
    /* Hide desktop tabs on mobile */
    .tabs-desktop {
        display: none !important;
    }
    
    /* Show mobile bottom tabs */
    .mobile-bottom-tabs {
        display: flex;
    }
    
    /* Mobile Bottom Tabs */
    .mobile-bottom-tabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--card);
        border-top: 1px solid var(--border);
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0.5rem 0;
        z-index: 100;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-tab-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        padding: 0.5rem 0.75rem;
        background: none;
        border: none;
        color: var(--muted-foreground);
        font-size: 0.75rem;
        cursor: pointer;
        transition: var(--transition);
        flex: 1;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .mobile-tab-btn svg {
        width: 22px;
        height: 22px;
    }
    
    .mobile-tab-btn.active {
        color: var(--primary);
        font-weight: 600;
        position: relative;
    }
    
    .mobile-tab-btn.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 3px;
        background: var(--primary);
        border-radius: 0 0 3px 3px;
    }
    
    .mobile-tab-btn.active svg {
        filter: drop-shadow(0 2px 4px rgba(20, 184, 166, 0.3));
    }
    
    .mobile-tab-btn span {
        font-size: 0.7rem;
        font-weight: 500;
    }
    
    /* Mobile More Menu */
    .mobile-more-menu {
        position: fixed;
        bottom: 4rem;
        right: 1rem;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-xl);
        padding: 0.5rem;
        display: none;
        flex-direction: column;
        gap: 0.25rem;
        z-index: 200;
        min-width: 180px;
    }
    
    .mobile-more-menu.active {
        display: flex;
    }
    
    .mobile-more-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.875rem 1rem;
        background: none;
        border: none;
        text-align: left;
        color: var(--foreground);
        font-size: 0.875rem;
        cursor: pointer;
        border-radius: var(--radius-sm);
        transition: var(--transition);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    .mobile-more-item:hover,
    .mobile-more-item:active {
        background: var(--muted);
    }
    
    .mobile-more-item svg {
        width: 20px;
        height: 20px;
    }
    
    /* Add padding to main content for bottom tabs */
    .loan-details-page {
        padding-bottom: 4.5rem;
    }
    
    /* Floating Action Button */
    .fab-container {
        position: fixed;
        bottom: 5.5rem;
        right: 1.25rem;
        z-index: 300;
    }
    
    .fab-button {
        width: 3.5rem;
        height: 3.5rem;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 0 6px rgba(255, 255, 255, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: var(--transition);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        z-index: 2;
    }
    
    .fab-button:active {
        transform: scale(0.95);
    }
    
    .fab-icon {
        transition: transform 0.3s ease;
    }
    
    .fab-container.active .fab-icon {
        transform: rotate(45deg);
    }
    
    .fab-menu {
        position: absolute;
        bottom: 0;
        right: 0;
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 4.5rem;
        opacity: 0;
        visibility: hidden;
        transform: translateY(1rem);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
    }
    
    .fab-container.active .fab-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: all;
    }
    
    .fab-option {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.875rem 1.25rem;
        background: var(--card);
        color: var(--foreground);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-md);
        font-size: 0.9375rem;
        font-weight: 500;
        cursor: pointer;
        transition: var(--transition);
        white-space: nowrap;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        min-height: 3rem;
    }
    
    .fab-option:hover,
    .fab-option:active {
        background: var(--primary);
        color: white;
        transform: translateX(-4px);
        box-shadow: var(--shadow-lg);
    }
    
    .fab-option svg {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }
    
    /* Mobile Modals */
    .mobile-modal {
        align-items: flex-end;
    }
    
    .mobile-modal .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin: 0;
        max-height: 90vh;
        animation: slideUpMobile 0.3s ease;
        position: relative;
    }
    
    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    .mobile-modal .modal-header {
        position: sticky;
        top: 0;
        background: var(--card);
        z-index: 1;
        border-bottom: 1px solid var(--border);
    }
    
    .mobile-modal .modal-body {
        max-height: calc(90vh - 4rem);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* KPI Tab for Mobile */
    .mobile-kpis {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem 0;
    }
    
    .mobile-kpis .stat-card {
        padding: 1.25rem;
    }
    
    /* Hide action bar on mobile */
    .action-bar {
        display: none !important;
    }
    
    /* CRITICAL: Hide desktop summary cards on mobile - duplicate rule for extra safety */
    div#desktop-summary-cards,
    #desktop-summary-cards,
    .desktop-summary-cards,
    .summary-cards.desktop-summary-cards {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
        width: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
    
    /* Ensure mobile-kpis inside kpis-tab are visible ONLY when kpis-tab is active */
    #kpis-tab.active .mobile-kpis.summary-cards,
    #kpis-tab.active .mobile-kpis {
        display: grid !important;
        visibility: visible !important;
        height: auto !important;
        position: relative !important;
        left: auto !important;
        width: auto !important;
        opacity: 1 !important;
    }
    
    /* Hide mobile-kpis when kpis-tab is not active */
    #kpis-tab:not(.active) .mobile-kpis,
    #kpis-tab:not(.active) .mobile-kpis.summary-cards {
        display: none !important;
    }
    
    /* Summary cards adjustments - only for mobile-kpis when visible */
    .mobile-kpis.summary-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    /* Tab content adjustments */
    .tab-content {
        padding-bottom: 1rem;
    }
    
    /* Better spacing for cards in tabs */
    .tab-content .card {
        margin-bottom: 1rem;
    }
}

/* Additional mobile optimizations for very small screens */
@media (max-width: 480px) {
    .fab-container {
        bottom: 5rem;
        right: 1rem;
    }
    
    .fab-button {
        width: 3.25rem;
        height: 3.25rem;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15), 0 0 0 2px rgba(255, 255, 255, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.2);
    }
    
    .fab-option {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .mobile-bottom-tabs {
        padding: 0.375rem 0;
    }
    
    .mobile-tab-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .mobile-tab-btn svg {
        width: 20px;
        height: 20px;
    }
}
