* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 10px;
    padding-top: env(safe-area-inset-top, 10px);
    padding-bottom: env(safe-area-inset-bottom, 10px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    min-height: calc(100vh - 20px);
    min-height: calc(100dvh - 20px);
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 20px;
    padding-top: calc(25px + env(safe-area-inset-top, 0px));
    text-align: center;
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 3px;
    font-weight: 700;
}

.subtitle {
    opacity: 0.95;
    font-size: 0.95em;
}

.main-content {
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

.accounts-tabs {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.accounts-tabs h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.15em;
    font-weight: 600;
}

.add-account {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.add-account input {
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    -webkit-appearance: none;
}

.add-account button {
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.2s, background 0.2s;
    -webkit-appearance: none;
}

.add-account button:active {
    transform: scale(0.96);
    background: #5a6fd6;
}

.tabs-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.account-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.account-tab.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.account-tab .account-name {
    flex: 1;
}

.account-tab .account-balance {
    font-weight: 600;
}

.account-tab .delete-account {
    padding: 4px 6px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    transition: background 0.2s;
}

.account-tab .delete-account:active {
    background: #c82333;
}

.dashboard {
    padding: 20px;
}

.account-header {
    margin-bottom: 20px;
}

.account-header h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.4em;
    font-weight: 700;
}

.balance-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.balance-item {
    padding: 16px 12px;
    background: #f8f9fa;
    border-radius: 16px;
    text-align: center;
}

.balance-item .label {
    display: block;
    color: #666;
    margin-bottom: 6px;
    font-size: 0.8em;
    font-weight: 500;
}

.balance-item .value {
    display: block;
    font-size: 1.2em;
    font-weight: 700;
    color: #333;
}

.balance-item .value.income {
    color: #28a745;
}

.balance-item .value.expense {
    color: #dc3545;
}

.add-transaction {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.add-transaction h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    color: #555;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    background: white;
    -webkit-appearance: none;
}

#addTransactionBtn {
    width: 100%;
    padding: 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.2s, background 0.2s;
    -webkit-appearance: none;
}

#addTransactionBtn:active {
    transform: scale(0.96);
    background: #5a6fd6;
}

.transactions-history h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.transactions-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.transactions-table thead {
    background: #f8f9fa;
}

.transactions-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e9ecef;
    font-size: 0.9em;
}

.transactions-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.9em;
}

.transaction-row.income {
    background: rgba(40, 167, 69, 0.05);
}

.transaction-row.expense {
    background: rgba(220, 53, 69, 0.05);
}

.transaction-row:hover {
    background: rgba(0, 0, 0, 0.02);
}

.transaction-description {
    font-weight: 500;
    color: #333;
}

.transaction-date {
    color: #666;
}

.transaction-type {
    font-weight: 500;
}

.transaction-amount {
    font-weight: 600;
    white-space: nowrap;
}

.transaction-row.income .transaction-amount {
    color: #28a745;
}

.transaction-row.expense .transaction-amount {
    color: #dc3545;
}

.transaction-actions {
    text-align: center;
}

.delete-transaction {
    padding: 6px 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: transform 0.2s, background 0.2s;
    -webkit-appearance: none;
}

.delete-transaction:active {
    transform: scale(0.96);
    background: #c82333;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 0.95em;
}

@media (max-width: 900px) {
    body {
        padding: 0;
    }
    
    .container {
        border-radius: 0;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .accounts-panel {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .balance-info {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.6em;
    }
    
    .balance-item .value {
        font-size: 1.3em;
    }
}