:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --modal-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --border-color: #334155;
        --card-bg: #1e293b;
        --modal-bg: #0f172a;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-primary);
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* Header */
.header {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

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

.btn-icon {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.3);
}

/* Main Content */
.main {
    padding: 0.75rem;
    padding-bottom: 1.5rem;
}

/* Balance Card */
.balance-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.balance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.balance-item.small {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    padding: 0.5rem;
    border-radius: 8px;
    background: var(--bg-secondary);
}

.balance-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.balance-amount {
    font-size: 2rem;
    font-weight: 700;
    color: #059669;
}

.balance-breakdown {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.balance-breakdown .balance-item:first-child {
    border-left: 4px solid #16a34a;
}

.balance-breakdown .balance-item:last-child {
    border-left: 4px solid #dc2626;
}

/* Reminders Card */
.reminders-card {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.reminders-card h3 {
    color: #92400e;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.reminder-item {
    background: white;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    border-left: 3px solid #f59e0b;
    font-size: 0.85rem;
}

.reminder-item:last-child {
    margin-bottom: 0;
}

.reminder-text {
    font-weight: 500;
    color: #92400e;
}

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

.section-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Buttons */
.btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 44px;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 44px;
}

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

/* Account Cards */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.account-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.account-card:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37,99,235,0.1);
}

.account-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.25rem;
}

.account-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.account-type {
    background: var(--border-color);
    color: var(--text-secondary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: capitalize;
}

.account-type.credit {
    background: #fecaca;
    color: #dc2626;
}

.account-type.checking {
    background: #dbeafe;
    color: #2563eb;
}

.account-type.savings {
    background: #dcfce7;
    color: #16a34a;
}

.account-balance {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.account-balance.negative {
    color: #dc2626;
}

.account-balance.positive {
    color: #16a34a;
}

.account-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.delete-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #ef4444;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.account-card:hover .delete-btn {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    padding: 1rem;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--modal-bg);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 0;
    margin-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Form */
.form-group {
    margin-bottom: 1rem;
    padding: 0 1.5rem;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    min-height: 44px;
    background: var(--card-bg);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1.5rem;
    padding-top: 0;
}

.form-actions button {
    flex: 1;
}

/* Responsive */
@media (max-width: 480px) {
    .app {
        box-shadow: none;
    }
    
    .main {
        padding: 0.75rem;
    }
    
    .balance-amount {
        font-size: 1.75rem;
    }
}

.account-section-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

/* Smaller Accounts Section */
.smaller-accounts-section {
    margin-top: 1rem;
}

.smaller-accounts-toggle {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.smaller-accounts-toggle:hover {
    background: var(--border-color);
}

.smaller-accounts-list {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.smaller-accounts-list .account-card {
    opacity: 0.8;
    transform: scale(0.98);
}

.smaller-accounts-list .account-card:hover {
    opacity: 1;
    transform: scale(1);
}

.sync-status {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.status-item:last-child {
    margin-bottom: 0;
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.sync-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.sync-actions button {
    flex: 1;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}
