:root {
    /* Sofi-like teal/blue palette */
    --primary-color: #0B3D91; /* muted navy */
    --primary-dark: #072A66;
    --primary-light: #F1F5FB;
    --secondary-color: #0B66A3;
    --accent-color: #0E7ACF;
    --background-color: #FFFFFF; /* clean white background for a bank-like look */
    --card-background: #FFFFFF;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #6B7280;
    --border-radius: 10px;
    --border-radius-sm: 8px;
    --padding-unit: 20px;
    --header-height: 60px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Realistic bank semantic colors */
    --success-color: #0F9D58; /* deposit/positive */
    --danger-color: #D9534F;  /* negative/alerts */
    --muted-panel: #F7FAFC;
}

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

html, body {
    overflow-x: hidden; /* prevent horizontal scrolling / elements escaping page bounds */
}

body {
    font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    font-weight: 400;
}

/* Header Styles */
header {
    background: var(--card-background);
    border-bottom: 1px solid #E6EEF9;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: none;
    height: var(--header-height);
    box-shadow: var(--shadow-sm);
}

.header-content {
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.nav-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 280px;
}

/* make nav horizontally scrollable when necessary and keep it visually compact */
nav {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    position: static;
    left: auto;
    transform: none;
    bottom: auto;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    z-index: 2;
    max-width: 100%;
    width: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

/* subtle padding for nav on small screens */
nav::-webkit-scrollbar { height: 6px; }
nav::-webkit-scrollbar-thumb { background: rgba(11,61,145,0.12); border-radius: 10px; }

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    font-size: 12px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.nav-btn:hover {
    background: rgba(11,61,145,0.04);
    color: var(--primary-dark);
}

.nav-btn.active {
    background: rgba(11,61,145,0.08);
    color: var(--primary-dark);
    box-shadow: none;
}

.nav-icon {
    font-size: 20px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.notification-btn, .profile-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: background-color 0.2s ease;
}

.notification-btn:hover, .profile-btn:hover {
    background: #F1F5F9;
}

.notification-icon {
    font-size: 20px;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--primary-color), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* Main Content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    padding-top: calc(var(--header-height) + 12px);
    box-sizing: border-box;
    padding-bottom: 120px; /* reduced reserved space now nav is in header */
}

/* Hero Section */
.hero-section {
    background: linear-gradient(180deg, rgba(11,61,145,0.02), transparent 60%);
    border-radius: 12px;
    padding: 28px;
    margin-bottom: 24px;
    border: 1px solid #EEF3FB;
    color: var(--text-primary);
}

.hero-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap; /* allow wrapping on small screens */
}

.hero-content > * {
    min-width: 280px;
    flex: 1 1 320px;
}

.welcome-text h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-text p {
    color: var(--text-secondary);
    font-size: 16px;
}

.balance-display {
    text-align: right;
}

.balance-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

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

.balance-change {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.change-positive {
    color: var(--success-color);
    font-weight: 600;
}

.change-period {
    color: var(--text-muted);
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border: 1px solid #E2E8F0;
    background: var(--card-background);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.action-btn:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--primary-color);
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 6px 18px rgba(11,61,145,0.06);
}

.action-icon {
    font-size: 20px;
}

/* Dashboard Sections */
.dashboard-section {
    background: var(--card-background);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 2px rgba(11,61,145,0.02);
    border: 1px solid #F1F6FB;
}

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

.section-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.section-action {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    transition: background-color 0.2s ease;
}

.section-action:hover {
    background: var(--primary-light);
}

/* Account Cards */
.account-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.account-card {
    padding: 16px;
    border-radius: 10px;
    border: 1px solid #F1F6FB;
    background: var(--card-background);
    transition: box-shadow 0.16s ease, transform 0.12s ease;
}

.account-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(11,61,145,0.04);
}

.account-card .account-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.account-meta {
    flex: 1 1 auto;
    min-width: 160px;
}

.account-balance-block {
    text-align: right;
    min-width: 140px;
}

.account-card .account-card-footer {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.account-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.account-type {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.account-balance {
    font-size: 28px;
    font-weight: 700;
    margin-top: 16px;
}

/* Transactions */
.filter-tabs {
    display: flex;
    gap: 8px;
}

.filter-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
}

.filter-tab.active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.transactions-container {
    margin-top: 24px;
}

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

#transactions-table th {
    padding: 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #F1F5F9;
}

#transactions-table td {
    padding: 16px;
    border-bottom: 1px solid #F8FAFC;
}

#transactions-table tbody tr:hover {
    background: #F8FAFC;
}

.amount {
    font-weight: 600;
}

.amount.credit {
    color: var(--success-color);
}

.amount.debit {
    color: var(--danger-color);
}

/* Add pending status style */
.status-pending {
    color: var(--danger-color);
    font-weight: 600;
}

.view-all-btn {
    margin-top: 20px;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
}

.view-all-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

/* Insights */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.insight-card {
    padding: 24px;
    border-radius: var(--border-radius);
    border: 1px solid #E2E8F0;
    background: var(--card-background);
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.insight-icon {
    font-size: 24px;
}

.insight-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.insight-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.insight-change {
    font-size: 14px;
    font-weight: 500;
}

.insight-change.positive {
    color: var(--success-color);
}

.insight-change.negative {
    color: var(--danger-color);
}

.progress-bar {
    height: 8px;
    background: #F1F5F9;
    border-radius: 4px;
    margin: 16px 0 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.insight-details {
    font-size: 12px;
    color: var(--text-muted);
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #F1F5F9;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Forms */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #E2E8F0;
    border-radius: var(--border-radius-sm);
    font-size: 16px;
    transition: border-color 0.2s ease;
    background: var(--card-background);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

.form-select {
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 16px;
    margin-top: 32px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #F1F5F9;
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: #E2E8F0;
}

/* File Upload */
.file-upload-area {
    position: relative;
    border: 2px dashed #E2E8F0;
    border-radius: var(--border-radius-sm);
    padding: 40px;
    text-align: center;
    transition: border-color 0.2s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.file-upload-placeholder span:last-child {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Page Navigation */
.page-content {
    animation: fadeIn 0.3s ease;
}

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

/* Statements */
.statements-container {
    display: grid;
    gap: 16px;
}

.statement-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border: 1px solid #E2E8F0;
    border-radius: var(--border-radius-sm);
    background: var(--card-background);
}

.statement-item:hover {
    border-color: var(--primary-color);
}

.statement-info h4 {
    margin-bottom: 4px;
    font-size: 16px;
}

.statement-info p {
    color: var(--text-muted);
    font-size: 14px;
}

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

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

/* Accounts Detailed */
.accounts-detailed-container {
    display: grid;
    gap: 24px;
}

.detailed-account-card {
    padding: 24px;
    border-radius: var(--border-radius);
    border: 1px solid #E2E8F0;
    background: var(--card-background);
}

.detailed-account-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.account-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.detail-item {
    padding: 16px;
    background: #F8FAFC;
    border-radius: var(--border-radius-sm);
}

.detail-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-value {
    font-size: 18px;
    font-weight: 600;
}

/* External Accounts */
.external-accounts-container {
    display: grid;
    gap: 16px;
}

.external-account-card {
    position: relative;
    overflow: hidden;
}

.external-account-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.external-account-form {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #E2E8F0;
}

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

.btn-danger:hover {
    background: #DC2626;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content { padding: 0 12px; height: auto; flex-direction: column; align-items: stretch; gap: 10px; }
    .logo-section { align-items: flex-start; padding-top: 8px; }
    .nav-wrap { order: 2; width: 100%; }
    nav { padding: 8px 6px; justify-content: flex-start; }
    .header-actions { order: 3; align-self: flex-end; padding-bottom: 8px; }
    main {
        padding: 12px;
        padding-top: calc(var(--header-height) + 8px);
        padding-bottom: 100px;
    }
    .quick-actions { grid-template-columns: 1fr; gap: 12px; }
    .account-card { padding: 14px; border-radius: 12px; }
    .balance-amount { font-size: 36px; }
    .nav-btn {
        padding: 8px 10px;
        font-size: 11px;
    }
    .account-cards-container {
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .header-content { /* keep content in a row so actions stay top-right */ 
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
    .logo-section { padding-top: 0; }
    .nav-wrap { order: 2; width: auto; flex: 1; }
    .header-actions { order: 3; margin-left: auto; align-self: center; padding-bottom: 0; }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 12px;
    }

    .logo {
        font-size: 20px;
    }

    .logo-subtitle {
        display: none;
    }

    .nav-btn {
        padding: 6px 8px;
        font-size: 10px;
    }
}

@media (max-width: 920px) {
    nav { gap: 8px; }
    /* ensure main content has comfortable bottom spacing */
    main { padding-bottom: 110px; }
}

.hidden {
    display: none;
}

.text-right { text-align: right; }