* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #F5F5F5;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: linear-gradient(135deg, #1E88E5 0%, #1565C0 100%);
    color: white;
    padding: 8px 12px;
    padding-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-title { font-size: 16px; font-weight: 600; }
.header-row { display: flex; justify-content: space-between; align-items: center; }
.header-subtitle { font-size: 14px; opacity: 0.9; margin-top: 4px; }
.back-btn { background: none; border: none; color: white; font-size: 14px; cursor: pointer; text-decoration: none; display: flex; align-items: center; gap: 4px; }
.add-btn { background: white; color: #1E88E5; border: none; padding: 10px 16px; border-radius: 20px; font-size: 14px; font-weight: 600; cursor: pointer; }

.app-content { flex: 1; overflow-y: auto; padding: 16px; }
.app-content.no-padding { padding: 0; }

.message { padding: 12px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; text-align: center; }
.message.success { background: #E8F5E9; color: #43A047; }
.message.error { background: #FFEBEE; color: #E53935; }

.section { background: white; border-radius: 16px; padding: 20px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.section-title { font-size: 16px; font-weight: 600; color: #212121; margin-bottom: 16px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: #757575; margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px; border: 2px solid #E0E0E0; border-radius: 8px; font-size: 15px; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #1E88E5; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.form-section { background: #F5F5F5; padding: 12px; border-radius: 8px; margin-bottom: 12px; }
.form-section-title { font-size: 13px; font-weight: 600; color: #1E88E5; margin-bottom: 10px; }

.btn { width: 100%; padding: 16px; border: none; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.btn-primary { background: #1E88E5; color: white; }
.btn-primary:hover { background: #1565C0; }
.btn-secondary { background: #F5F5F5; color: #757575; }
.btn-danger { background: #FFEBEE; color: #E53935; }
.btn-danger:hover { background: #FFCDD2; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; padding: 14px; margin-top: 0; }

.info-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #F5F5F5; }
.info-row:last-child { border-bottom: none; }
.info-label { color: #757575; font-size: 15px; }
.info-value { color: #212121; font-size: 15px; font-weight: 500; }

.card { background: white; border-radius: 12px; padding: 16px; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.card-avatar { width: 48px; height: 48px; background: #E3F2FD; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.card-info { flex: 1; }
.card-name { font-size: 16px; font-weight: 600; color: #212121; }
.card-email { font-size: 13px; color: #757575; }
.card-email a { color: inherit; text-decoration: none; }
.card-email a:hover { text-decoration: underline; }
.card-phone { font-size: 13px; color: #757575; }
.card-phone a { color: inherit; text-decoration: none; }
.card-phone a:hover { text-decoration: underline; }
.card-role { font-size: 12px; padding: 4px 8px; border-radius: 4px; background: #E3F2FD; color: #1E88E5; }
.card-role.admin { background: #FFF3E0; color: #E65100; }
.card-actions { display: flex; gap: 8px; }
.card-actions-right { display: flex; gap: 8px; margin-left: auto; }
.action-btn { background: none; border: none; padding: 8px; cursor: pointer; font-size: 18px; }
.view-btn { background: #1E88E5; color: white; border: none; padding: 8px 16px; border-radius: 6px; font-size: 13px; cursor: pointer; text-decoration: none; }

.balance-card { background: white; border-radius: 12px; padding: 20px; margin: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.balance-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.balance-label { color: #757575; font-size: 14px; }
.balance-value { font-size: 16px; font-weight: 600; }
.balance-value.credit { color: #43A047; }
.balance-value.debit { color: #E53935; }
.balance-total { border-top: 1px solid #E0E0E0; padding-top: 12px; margin-top: 12px; }
.balance-total .balance-value { font-size: 24px; }
.balance-total .balance-value.negative { color: #E53935; }
.balance.negative { color: #E53935; }
.balance.positive { color: #43A047; }
body.dark .balance.negative { color: #EF5350; }
body.dark .balance.positive { color: #66BB6A; }

.entry-card { background: white; border-radius: 12px; padding: 14px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); display: flex; align-items: flex-start; gap: 12px; }
.entry-card.cleared { opacity: 0.7; background: #FAFAFA; }
.entry-checkbox { width: 20px; height: 20px; margin-top: 2px; }
.entry-info { flex: 1; }
.entry-header { display: flex; justify-content: space-between; align-items: center; }
.entry-type { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; }
.entry-type.credit { background: #E8F5E9; color: #43A047; }
.entry-type.debit { background: #FFEBEE; color: #E53935; }
.entry-amount { font-size: 16px; font-weight: 700; }
.entry-amount.credit { color: #43A047; }
.entry-amount.debit { color: #E53935; }
.entry-date { font-size: 12px; color: #757575; margin-top: 4px; }
.entry-desc { font-size: 14px; color: #212121; margin-top: 4px; }
.entry-comments { font-size: 13px; color: #757575; font-style: italic; margin-top: 2px; }

.radio-group { display: flex; gap: 12px; }
.radio-option { flex: 1; display: flex; align-items: center; justify-content: center; padding: 12px; border: 2px solid #E0E0E0; border-radius: 8px; cursor: pointer; font-weight: 600; }
.radio-option.selected { border-color: #1E88E5; background: #E3F2FD; color: #1E88E5; }
.radio-option.credit.selected { border-color: #43A047; background: #E8F5E9; color: #43A047; }
.radio-option.debit.selected { border-color: #E53935; background: #FFEBEE; color: #E53935; }

.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group input { width: auto; }

.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal.show { display: flex; }
.modal-content { background: white; border-radius: 16px; padding: 24px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.modal-content.narrow { max-width: 360px; }
.modal h2 { font-size: 20px; margin-bottom: 20px; }

.nav-bar { background: white; border-top: 1px solid #E0E0E0; display: flex; padding: 8px 0; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px; text-decoration: none; color: #757575; font-size: 11px; gap: 4px; }
.nav-item.active { color: #1E88E5; }
.nav-item .icon { font-size: 22px; }

.empty-state { text-align: center; padding: 40px; color: #757575; }
.app-logo { width: 60px; height: 60px; background: linear-gradient(135deg, #1E88E5 0%, #1565C0 100%); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 16px; }
.app-name { text-align: center; font-size: 20px; font-weight: 600; color: #212121; }
.app-tagline { text-align: center; color: #757575; font-size: 14px; margin-bottom: 24px; }
.profile-avatar { width: 80px; height: 80px; background: linear-gradient(135deg, #1E88E5 0%, #1565C0 100%); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 36px; margin: 0 auto 16px; color: white; }
.profile-name { font-size: 22px; font-weight: 600; color: #212121; text-align: center; }
.profile-email { font-size: 14px; color: #757575; margin-top: 4px; text-align: center; }
.profile-role { display: inline-block; margin-top: 12px; padding: 6px 16px; background: #E3F2FD; color: #1E88E5; border-radius: 20px; font-size: 13px; font-weight: 500; text-transform: capitalize; }
.welcome-card { background: linear-gradient(135deg, #1E88E5 0%, #1565C0 100%); border-radius: 12px; padding: 12px; color: white; margin-bottom: 12px; }
.welcome-card h2 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.welcome-card p { font-size: 10px; opacity: 0.9; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.stat-card .icon { width: 40px; height: 40px; background: #E3F2FD; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 12px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #212121; }
.stat-card .label { font-size: 13px; color: #757575; margin-top: 4px; }

/* Responsive Design - Mobile First */

/* Tablet breakpoint (768px and up) */
@media (min-width: 768px) {
    /* Layout adjustments */
    .app-content {
        padding: 24px;
        max-width: 1200px;
        margin: 0 auto;
    }
    
    /* Card grid layout */
    .card-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .card {
        margin-bottom: 0;
    }
    
    /* Stats grid expansion */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Section improvements */
    .section {
        padding: 24px;
    }
    
    /* Form improvements */
    .form-row {
        gap: 16px;
    }
    
    /* Modal improvements for tablet */
    .modal-content {
        max-width: 500px;
    }
    
    /* Better buttons on larger screens */
    .btn {
        padding: 14px 24px;
    }
    
    .btn-row .btn {
        padding: 12px 20px;
    }
}

/* Desktop breakpoint (1024px and up) */
@media (min-width: 1024px) {
    /* Main layout with sidebar */
    body {
        flex-direction: row;
    }
    
    .app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        padding: 12px 24px;
    }
    
    .app-content {
        margin-left: 240px;
        margin-top: 60px;
        padding: 32px;
        min-height: calc(100vh - 60px);
    }
    
    /* Card grid - 3 columns on desktop */
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    
    /* Side navigation for desktop */
    .nav-bar {
        position: fixed;
        left: 0;
        top: 60px;
        bottom: 0;
        width: 240px;
        flex-direction: column;
        border-top: none;
        border-right: 1px solid #E0E0E0;
        padding: 16px 0;
        overflow-y: auto;
    }
    
    .nav-item {
        flex-direction: row;
        padding: 12px 24px;
        font-size: 14px;
        gap: 12px;
        justify-content: flex-start;
    }
    
    .nav-item .icon {
        font-size: 20px;
    }
    
    /* Modal improvements for desktop */
    .modal-content {
        max-width: 600px;
        max-height: 85vh;
    }
    
    .modal-content.wide {
        max-width: 800px;
    }
    
    /* Stats grid - 4 columns */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    
    .stat-card {
        padding: 24px;
    }
    
    .stat-card .value {
        font-size: 32px;
    }
    
    /* Typography improvements */
    .section-title {
        font-size: 18px;
    }
    
    .card-name {
        font-size: 17px;
    }
    
    /* Info row improvements */
    .info-row {
        padding: 16px 0;
    }
    
    .info-label,
    .info-value {
        font-size: 16px;
    }
    
    /* Balance card improvements */
    .balance-card {
        max-width: 600px;
        margin: 24px auto;
        padding: 28px;
    }
    
    .balance-total .balance-value {
        font-size: 28px;
    }
    
    /* Form improvements */
    .form-group {
        margin-bottom: 18px;
    }
    
    .form-group label {
        font-size: 14px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px;
        font-size: 16px;
    }
    
    /* Welcome card */
    .welcome-card {
        padding: 20px;
    }
    
    .welcome-card h2 {
        font-size: 18px;
    }
    
    .welcome-card p {
        font-size: 14px;
    }
}

/* Large desktop breakpoint (1440px and up) */
@media (min-width: 1440px) {
    .app-content {
        max-width: 1400px;
        padding: 40px;
    }
    
    /* 4 column card grid on large screens */
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Wider modals */
    .modal-content.wide {
        max-width: 1000px;
    }
}

body.dark {
    background: #121212;
    color: #E0E0E0;
}
body.dark .app-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
body.dark .header-logo {
    background: #333;
}
body.dark .section {
    background: #1E1E1E;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
body.dark .section-title {
    color: #E0E0E0;
}
body.dark .form-group label {
    color: #9E9E9E;
}
body.dark .form-group input,
body.dark .form-group select,
body.dark .form-group textarea {
    background: #2C2C2C;
    border-color: #424242;
    color: #E0E0E0;
}
body.dark .form-group input:focus,
body.dark .form-group select:focus,
body.dark .form-group textarea:focus {
    border-color: #64B5F6;
}
body.dark .form-section {
    background: #2C2C2C;
}
body.dark .form-section-title {
    color: #64B5F6;
}
body.dark .card {
    background: #1E1E1E;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
body.dark .card-avatar {
    background: #2C2C2C;
}
body.dark .card-name {
    color: #E0E0E0;
}
body.dark .card-email,
body.dark .card-phone {
    color: #9E9E9E;
}
body.dark .card-email a,
body.dark .card-phone a {
    color: inherit;
}
body.dark .card-role {
    background: #2C2C2C;
    color: #64B5F6;
}
body.dark .card-role.admin {
    background: #3E2723;
    color: #FFB74D;
}
body.dark .nav-bar {
    background: #1E1E1E;
    border-top-color: #333;
}
body.dark .nav-item {
    color: #9E9E9E;
}
body.dark .nav-item.active {
    color: #64B5F6;
}
body.dark .btn-secondary {
    background: #333;
    color: #9E9E9E;
}
body.dark .message.success {
    background: #1B3A2B;
    color: #81C784;
}
body.dark .message.error {
    background: #3E1A1A;
    color: #EF5350;
}
body.dark .filter-bar,
body.dark .filter-tabs {
    background: #1E1E1E;
}
body.dark .filter-tab {
    background: #2C2C2C;
    color: #9E9E9E;
}
body.dark .filter-tab.active {
    background: #64B5F6;
    color: #121212;
}
body.dark .empty-state {
    color: #9E9E9E;
}
body.dark .modal-content {
    background: #1E1E1E;
    color: #E0E0E0;
}
body.dark .modal h2 {
    color: #E0E0E0;
}
body.dark .info-row {
    border-bottom-color: #333;
}
body.dark .info-label {
    color: #9E9E9E;
}
body.dark .info-value {
    color: #E0E0E0;
}
body.dark .balance-card {
    background: #1E1E1E;
}
body.dark .balance-label {
    color: #9E9E9E;
}
body.dark .entry-card {
    background: #1E1E1E;
}
body.dark .entry-card.cleared {
    background: #252525;
}
body.dark .entry-desc {
    color: #E0E0E0;
}
body.dark .entry-date {
    color: #9E9E9E;
}
body.dark .radio-option {
    border-color: #424242;
    background: #2C2C2C;
    color: #9E9E9E;
}
body.dark .radio-option.selected {
    border-color: #64B5F6;
    background: #1a237e;
    color: #64B5F6;
}
body.dark .view-btn {
    background: #64B5F6;
    color: #121212;
}
body.dark .app-logo {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
body.dark .app-name {
    color: #E0E0E0;
}
body.dark .app-tagline {
    color: #9E9E9E;
}
body.dark .profile-avatar {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
body.dark .profile-name {
    color: #E0E0E0;
}
body.dark .profile-email {
    color: #9E9E9E;
}
body.dark .stat-card {
    background: #1E1E1E;
}
body.dark .stat-card .value {
    color: #E0E0E0;
}
body.dark .stat-card .label {
    color: #9E9E9E;
}
body.dark .stat-card .icon {
    background: #2C2C2C;
}
body.dark .add-btn {
    background: #64B5F6;
    color: #121212;
}
body.dark .profile-role {
    background: #2C2C2C;
    color: #64B5F6;
}
body.dark .welcome-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
body.dark .member-checkboxes {
    background: #1E1E1E;
    border-color: #333;
}
body.dark .member-checkbox {
    border-bottom-color: #333;
}
body.dark .billing-tabs,
body.dark .billing-tab {
    background: #1E1E1E;
}
body.dark .billing-tab {
    color: #9E9E9E;
}
body.dark .billing-tab.active {
    background: #64B5F6;
    color: #121212;
}
body.dark .toast-modal {
    background: #1E1E1E;
    color: #E0E0E0;
}
body.dark .toast-modal h3 {
    color: #E0E0E0;
}
body.dark .toast-modal p {
    color: #9E9E9E;
}
body.dark .image-modal {
    background: rgba(0,0,0,0.95);
}

/* Settings tabs */
body.dark .settings-tabs,
body.dark .billing-tabs {
    background: #1E1E1E;
}
body.dark .settings-tab,
body.dark .billing-tab {
    background: #2C2C2C;
    color: #9E9E9E;
}
body.dark .settings-tab.active,
body.dark .billing-tab.active {
    background: #64B5F6;
    color: #121212;
}
body.dark .feature-toggle {
    background: #2C2C2C;
}
body.dark .feature-toggle label {
    color: #E0E0E0;
}
body.dark .profile-tabs {
    background: #1E1E1E;
}
body.dark .profile-tab {
    background: #2C2C2C;
    color: #9E9E9E;
}
body.dark .profile-tab.active {
    background: #64B5F6;
    color: #121212;
}
body.dark .dashboard-feature {
    background: #2C2C2C;
}
body.dark .dashboard-feature label {
    color: #E0E0E0;
}

.dark-mode-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.dark-mode-toggle:hover {
    background: rgba(255,255,255,0.1);
}

/* Sponsors & Donors page specific */
body.dark .year-filter {
    background: #1E1E1E;
}
body.dark .filter-form label {
    color: #9E9E9E;
}
body.dark .filter-form select {
    background: #2C2C2C;
    border-color: #424242;
    color: #E0E0E0;
}
body.dark .year-total {
    color: #81C784;
}
body.dark .sponsorship-item,
body.dark .donation-item {
    background: #2C2C2C;
}
body.dark .sponsorship-date,
body.dark .sponsorship-ref,
body.dark .donation-date,
body.dark .donation-ref {
    color: #9E9E9E;
}
body.dark .sponsorship-desc,
body.dark .donation-desc {
    color: #E0E0E0;
}
body.dark .sponsorship-notes,
body.dark .donation-notes {
    color: #BDBDBD;
}
body.dark .sponsorship-total,
body.dark .donation-total {
    border-top-color: #424242;
    color: #E0E0E0;
}
body.dark .toast {
    background: #1E1E1E;
    border: 1px solid #333;
}
body.dark .toast-message {
    color: #E0E0E0;
}
body.dark .toast-close {
    color: #9E9E9E;
}
body.dark .toast-close:hover {
    color: #E0E0E0;
}
body.dark #confirmMessage {
    color: #9E9E9E;
}

/* Quick actions and other lists */
body.dark .quick-actions {
    background: #1E1E1E;
}
body.dark .quick-action-item {
    background: #2C2C2C;
}
body.dark .quick-action-item:active {
    background: #333;
}

/* Index page activity card */
body.dark .activity-card {
    background: #1E1E1E;
}
body.dark .activity-item {
    border-bottom-color: #333;
}
body.dark .activity-icon {
    background: #2C2C2C;
}
body.dark .activity-text .title {
    color: #E0E0E0;
}
body.dark .activity-text .time {
    color: #9E9E9E;
}
body.dark .activity-total {
    color: #81C784;
}

body.dark .role-card {
    background: #1E1E1E;
}
body.dark .role-name {
    color: #E0E0E0;
}
body.dark .role-desc {
    color: #9E9E9E;
}
body.dark .role-badge.admin {
    background: #3E2723;
    color: #FFB74D;
}
body.dark .role-badge.user {
    background: #1a237e;
    color: #64B5F6;
}
body.dark .feature-toggle {
    background: #2C2C2C;
}
body.dark .feature-toggle span:first-child {
    color: #E0E0E0;
}
