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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    line-height: 1.5;
    font-size: 16px;
    overflow-x: hidden;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 15px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 25px;
    position: relative;
}

.header h1 {
    font-size: 1.8em;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #888;
    font-size: 0.9em;
}

/* Month Navigator */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #16213e;
    border-radius: 12px;
}

.month-nav-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.month-nav-btn:hover {
    background: #667eea;
    transform: scale(1.1);
}

.month-display {
    font-size: 1.2em;
    font-weight: 600;
    min-width: 150px;
    text-align: center;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: #16213e;
    color: #888;
}

.tab:hover {
    background: #1a2744;
    color: #fff;
}

.tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab.income.active {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

.tab.expense.active {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

/* Balance Card */
.balance-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    margin-bottom: 20px;
    animation: fadeInUp 0.5s ease;
}

.balance-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.balance-amount {
    font-size: 2.5em;
    font-weight: 700;
    color: white;
    margin-bottom: 10px;
}

.balance-change {
    font-size: 0.9em;
    opacity: 0.9;
    padding: 5px 15px;
    border-radius: 20px;
    display: inline-block;
}

.balance-change.positive {
    background: rgba(39, 174, 96, 0.3);
}

.balance-change.negative {
    background: rgba(231, 76, 60, 0.3);
}

.balance-initial {
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 8px;
}

/* Chart Container */
.chart-container {
    background: #16213e;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    animation: fadeInUp 0.6s ease;
}

.chart-title {
    text-align: center;
    color: #888;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.chart-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.chart-center-amount {
    font-size: 1.3em;
    font-weight: 700;
}

.chart-center-label {
    font-size: 0.75em;
    color: #888;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    color: #aaa;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Add Button */
.add-section {
    margin-bottom: 20px;
}

.add-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    animation: fadeInUp 0.7s ease;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.add-btn:active {
    transform: scale(0.98);
}

/* Transactions List */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.transaction-group {
    margin-bottom: 15px;
}

.group-date {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
    padding-left: 5px;
}

.transaction-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #16213e;
    border-radius: 10px;
    gap: 12px;
    transition: all 0.3s;
    animation: slideInRight 0.4s ease;
    cursor: pointer;
}

.transaction-item:hover {
    background: #1a2744;
    transform: translateX(5px);
}

.transaction-item.income {
    border-left: 4px solid #27ae60;
}

.transaction-item.expense {
    border-left: 4px solid #e74c3c;
}

.transaction-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    flex-shrink: 0;
}

.transaction-icon.income {
    background: rgba(39, 174, 96, 0.2);
}

.transaction-icon.expense {
    background: rgba(231, 76, 60, 0.2);
}

.transaction-info {
    flex: 1;
    min-width: 0;
}

.transaction-category {
    font-weight: 600;
    font-size: 0.95em;
    margin-bottom: 2px;
}

.transaction-description {
    font-size: 0.8em;
    color: #666;
}

.transaction-amount {
    font-weight: 700;
    font-size: 1em;
    flex-shrink: 0;
}

.transaction-amount.income {
    color: #27ae60;
}

.transaction-amount.expense {
    color: #e74c3c;
}

.transaction-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.transaction-item:hover .transaction-actions {
    opacity: 1;
}

.transaction-action-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.2s;
    font-size: 14px;
}

.transaction-action-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.transaction-action-btn.delete:hover {
    color: #e74c3c;
}

/* Empty State */
.empty-state {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-size: 0.9em;
}

.empty-state-icon {
    font-size: 3em;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 15px;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #16213e;
    padding: 25px;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: scaleIn 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #888;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.modal h2 {
    margin-bottom: 20px;
    font-size: 1.3em;
    padding-right: 40px;
}

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

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px;
    border: 1px solid #333;
    border-radius: 10px;
    background: #1a1a2e;
    color: #fff;
    font-size: 16px;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-group input::placeholder {
    color: #555;
}

.type-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.type-btn {
    flex: 1;
    padding: 14px;
    border: 2px solid #333;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: #1a1a2e;
    color: #888;
}

.type-btn:hover {
    border-color: #555;
}

.type-btn.active.income {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.15);
    color: #27ae60;
}

.type-btn.active.expense {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 48px;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: #333;
    color: #fff;
}

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

.btn-small {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
    width: auto;
}

/* Initial Balance Modal */
.initial-modal .modal-content {
    max-width: 350px;
    text-align: center;
}

.initial-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.initial-title {
    font-size: 1.2em;
    margin-bottom: 8px;
}

.initial-subtitle {
    color: #888;
    font-size: 0.9em;
    margin-bottom: 20px;
}

/* Add Category */
.add-category-btn {
    background: none;
    border: 1px dashed #444;
    color: #666;
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s;
    margin-top: 5px;
}

.add-category-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

/* Loading */
.loading {
    text-align: center;
    color: #666;
    padding: 30px;
}

.loading::after {
    content: '';
    animation: loader 1s infinite;
}

@keyframes loader {
    0%, 100% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes countUp {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

/* Count animation */
.counting {
    animation: countUp 0.1s ease;
}

/* Stats summary */
.stats-summary {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.stat-item {
    flex: 1;
    background: #1a1a2e;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
}

.stat-item.income {
    border-top: 3px solid #27ae60;
}

.stat-item.expense {
    border-top: 3px solid #e74c3c;
}

.stat-label {
    font-size: 0.75em;
    color: #888;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.1em;
    font-weight: 700;
}

.stat-value.income {
    color: #27ae60;
}

.stat-value.expense {
    color: #e74c3c;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .balance-amount {
        font-size: 2em;
    }

    .month-nav {
        padding: 12px;
    }

    .month-display {
        font-size: 1em;
        min-width: 120px;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        padding: 10px;
        font-size: 13px;
    }

    .transaction-item {
        flex-wrap: wrap;
    }

    .transaction-amount {
        margin-left: auto;
    }

    .transaction-actions {
        width: 100%;
        opacity: 1;
        justify-content: flex-end;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid #333;
    }
}

@media (max-width: 400px) {
    body {
        font-size: 14px;
    }

    .balance-amount {
        font-size: 1.8em;
    }

    .chart-wrapper {
        width: 160px;
        height: 160px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .transaction-actions {
        opacity: 1;
    }

    .add-btn:hover {
        transform: none;
    }

    .add-btn:active {
        transform: scale(0.98);
    }
}

* {
    -webkit-tap-highlight-color: transparent;
}

/* Number input without spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Credit Tab */
.credit-section {
    animation: fadeInUp 0.5s ease;
}

.credit-setup {
    background: #16213e;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
}

.credit-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.credit-setup h2 {
    margin-bottom: 10px;
    font-size: 1.3em;
}

.credit-setup p {
    color: #888;
    margin-bottom: 20px;
}

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

.credit-header h2 {
    font-size: 1.3em;
    margin: 0;
}

.credit-edit-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #888;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.credit-edit-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.credit-progress-container {
    background: #16213e;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
}

.credit-progress-bar {
    height: 30px;
    background: #1a1a2e;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
    position: relative;
}

.credit-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    transition: width 1s ease;
    position: relative;
}

.credit-progress-fill.quarter {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.credit-progress-fill.halfway {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.credit-progress-fill.almost {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.credit-progress-fill.complete {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    animation: pulse 1s infinite;
}

@keyframes progressGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(102, 126, 234, 0.5); }
    50% { box-shadow: 0 0 40px rgba(102, 126, 234, 0.8); }
}

.credit-percent {
    text-align: center;
    font-size: 1.5em;
    font-weight: 700;
    color: #667eea;
}

.credit-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.credit-stat {
    flex: 1;
    background: #16213e;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}

.credit-stat-label {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 5px;
}

.credit-stat-value {
    font-size: 1.1em;
    font-weight: 700;
}

.credit-stat-value.paid {
    color: #27ae60;
}

.credit-motivation {
    text-align: center;
    font-size: 1.2em;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    animation: fadeInUp 0.5s ease;
}

.credit-motivation.complete {
    background: rgba(39, 174, 96, 0.2);
    color: #27ae60;
    font-size: 1.4em;
}

.credit-add-btn {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

.credit-add-btn:hover {
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.4);
}

.credit-payment-group {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #aaa;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.9em;
}

.tab.credit.active {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}