* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #2d2d2d;
    --success-color: #10b981;
    --danger-color: #ff4757;
    --warning-color: #ffa502;
    --safe-area-top: max(env(safe-area-inset-top), 10px);
    --safe-area-bottom: max(env(safe-area-inset-bottom), 10px);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.app-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    padding: calc(var(--safe-area-top) + 15px) 20px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    animation: slideDown 0.5s ease-out;
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    padding-bottom: 90px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

/* Tab Content */
.tab-content {
    animation: fadeIn 0.4s ease-in;
    display: none;
}

.tab-content.active {
    display: block;
    animation: slideUp 0.4s ease-out;
}

.section-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    animation: fadeIn 0.5s ease-in;
}

/* Forms */
.form-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    animation: slideUp 0.5s ease-out;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-tertiary);
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f5f7fa' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    -webkit-user-select: none;
    user-select: none;
}

.btn:active {
    opacity: 0.9;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    animation: slideUp 0.5s ease-out;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 107, 53, 0.1);
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.75rem;
    margin-top: 0;
    width: auto;
    border-radius: 6px;
    font-weight: 600;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 8px 28px rgba(255, 71, 87, 0.4);
}

/* Results */
.result-box {
    background: var(--bg-secondary);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
    animation: slideUp 0.4s ease-out;
}

.result-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    align-items: center;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-value {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.05rem;
}

/* Records List */
.records-list {
    animation: slideUp 0.5s ease-out;
}

.record-item {
    background: var(--bg-secondary);
    border-left: 3px solid var(--primary-color);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideUp 0.4s ease-out;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.record-item:hover {
    transform: translateX(4px);
    border-color: var(--primary-color);
}

.record-info {
    flex: 1;
}

.record-month {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.record-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.record-cost {
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

/* Summary Table */
.summary-table-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    animation: slideUp 0.5s ease-out;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table thead {
    background: var(--bg-tertiary);
}

.summary-table th {
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.summary-table td {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.summary-table tbody tr {
    transition: all 0.2s ease;
}

.summary-table tbody tr:hover {
    background-color: var(--bg-tertiary);
}

.summary-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
    animation: slideUp 0.5s ease-out;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--primary-color);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Charts */
.chart-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    animation: slideUp 0.5s ease-out;
    height: 300px;
}

#cost-chart {
    max-height: 100%;
}

/* Stats Insights */
.stats-insights {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 400px) {
    .stats-insights {
        grid-template-columns: 1fr 1fr;
    }
}

.insight-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: slideUp 0.5s ease-out;
    transition: all 0.3s ease;
}

.insight-card:hover {
    border-color: var(--primary-color);
}

.insight-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
    font-weight: 500;
}

.insight-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

/* Settings */
.settings-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
    animation: slideUp 0.5s ease-out;
}

.setting-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.setting-item label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.setting-item input,
.setting-item select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.setting-item input:focus,
.setting-item select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-tertiary);
}

.setting-item select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f5f7fa' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
    margin-bottom: 0;
}

.input-group .btn {
    flex: 0 0 auto;
    margin-top: 0;
    width: auto;
    padding: 12px 16px;
    font-size: 0.85rem;
    background: var(--primary-color);
    color: white;
    border: none;
}

.input-group .btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.setting-item.danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 0;
    padding-bottom: 16px;
}

.warning-text {
    font-size: 0.8rem;
    color: var(--warning-color);
    margin-top: 8px;
}

.settings-info {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    animation: slideUp 0.5s ease-out;
}

.settings-info h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.settings-info p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding-bottom: calc(var(--safe-area-bottom) + 4px);
    padding-top: 8px;
    z-index: 100;
    animation: slideUp 0.5s ease-out;
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
}

.nav-btn:hover {
    color: var(--primary-color);
}

.nav-btn.active {
    color: var(--primary-color);
}

.nav-btn.active::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: var(--primary-color);
    border-radius: 1px;
    animation: slideDown 0.3s ease-out;
}

.nav-icon {
    font-size: 1.5rem;
    display: block;
}

.nav-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    font-weight: 600;
}

/* Animations */
@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: none;
    }

    50% {
        box-shadow: none;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* iPhone 11 Pro specific adjustments */
@supports (padding: max(0px)) {
    .app-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }
}

/* Responsive adjustments */
@media (max-width: 390px) {
    .app-header h1 {
        font-size: 1.5rem;
    }

    .section-title {
        font-size: 1.2rem;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    .summary-stats {
        grid-template-columns: 1fr;
    }

    .stats-insights {
        grid-template-columns: 1fr;
    }
}

/* Income Tab Styles */
.income-summary {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.income-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.income-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.income-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.3px;
    font-weight: 500;
}

.income-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.income-value.net {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.2rem;
}

.breakdown-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.breakdown-row:last-child {
    border-bottom: none;
}

.breakdown-row.total {
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    margin-top: 4px;
    padding-top: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Print styles */
@media print {

    .bottom-nav,
    .btn {
        display: none;
    }

    .main-content {
        padding-bottom: 20px;
    }
}