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

:root {
    --primary-color: #2196F3;
    --success-color: #4CAF50;
    --warning-color: #FFC107;
    --danger-color: #F44336;
    --purple-color: #9C27B0;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
    --border-radius: 12px;
    --bottom-nav-height: 70px;
    --header-height: 60px;
}

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

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow);
    z-index: 1000;
}

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

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.menu-toggle:hover {
    background-color: rgba(255,255,255,0.1);
}

.app-main {
    margin-top: var(--header-height);
    padding: 20px;
    min-height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block;
}

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

.dashboard {
    max-width: 1200px;
    margin: 0 auto;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.summary-card i {
    font-size: 2rem;
    color: var(--primary-color);
}

.card-content h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.card-content span {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.quick-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    min-width: 150px;
    padding: 16px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
}

.action-btn.primary:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: var(--success-color);
    color: white;
}

.action-btn.secondary:hover {
    background: #388E3C;
    transform: translateY(-2px);
}

.metas-list {
    display: grid;
    gap: 16px;
}

.meta-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.meta-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.meta-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.meta-info h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.meta-category {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.meta-actions {
    display: flex;
    gap: 8px;
}

.meta-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.meta-btn.add {
    background: var(--success-color);
    color: white;
}

.meta-btn.add:hover {
    background: #388E3C;
    transform: scale(1.1);
}

.meta-btn.edit {
    background: var(--warning-color);
    color: white;
}

.meta-btn.edit:hover {
    background: #F57C00;
    transform: scale(1.1);
}

.meta-btn.delete {
    background: var(--danger-color);
    color: white;
}

.meta-btn.delete:hover {
    background: #D32F2F;
    transform: scale(1.1);
}

.meta-progress {
    margin-bottom: 16px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-amount {
    font-weight: 600;
    color: var(--text-primary);
}

.progress-percentage {
    font-weight: 600;
    color: var(--primary-color);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.meta-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.meta-date {
    display: flex;
    align-items: center;
    gap: 4px;
}

.days-remaining {
    font-weight: 600;
}

.days-remaining.urgent {
    color: var(--danger-color);
}

.days-remaining.warning {
    color: var(--warning-color);
}

.days-remaining.good {
    color: var(--success-color);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    color: var(--border-color);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.progress-container,
.strategy-container,
.calculator-container,
.faq-container {
    max-width: 800px;
    margin: 0 auto;
}

.progress-container h2,
.strategy-container h2,
.calculator-container h2,
.faq-container h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.chart-container {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.chart-container canvas {
    max-width: 100%;
    height: auto;
}

.milestones {
    display: grid;
    gap: 16px;
}

.milestone {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.milestone-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.milestone-icon.achieved {
    background: var(--success-color);
}

.milestone-icon.pending {
    background: var(--border-color);
    color: var(--text-secondary);
}

.milestone-content h4 {
    color: var(--text-primary);
    margin-bottom: 4px;
}

.milestone-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.income-form {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.income-form h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.suggestions {
    display: grid;
    gap: 16px;
}

.suggestion {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.suggestion h4 {
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggestion p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.calculator-form {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.probability-result {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow);
    text-align: center;
}

.probability-score {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.probability-score.high {
    color: var(--success-color);
}

.probability-score.medium {
    color: var(--warning-color);
}

.probability-score.low {
    color: var(--danger-color);
}

.probability-details {
    display: grid;
    gap: 12px;
    margin-top: 20px;
    text-align: left;
}

.probability-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.faq-list {
    display: grid;
    gap: 12px;
}

.faq-item {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    padding: 20px;
    background: none;
    border: none;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.faq-question:hover {
    background-color: #f8f9fa;
}

.faq-question[aria-expanded="true"] {
    background-color: var(--primary-color);
    color: white;
}

.faq-icon {
    font-size: 1.2rem;
    font-weight: 300;
    transition: transform 0.2s;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 20px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-answer:not([hidden]) {
    padding: 20px;
    max-height: 200px;
}

.faq-answer p {
    color: var(--text-secondary);
    line-height: 1.6;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn.primary {
    background: var(--primary-color);
    color: white;
}

.btn.primary:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

.btn.secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn.secondary:hover {
    background: #d0d0d0;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: var(--border-color);
}

.modal form {
    padding: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-radius: 8px;
    min-width: 60px;
}

.nav-item:hover {
    background-color: rgba(33, 150, 243, 0.1);
    color: var(--primary-color);
}

.nav-item.active {
    color: var(--primary-color);
    background-color: rgba(33, 150, 243, 0.1);
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 600;
}

footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: 16px;
    margin-top: 40px;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 600;
    z-index: 3000;
    animation: toastSlideIn 0.3s ease-out;
    max-width: 300px;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
}

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

@media (max-width: 768px) {
    .app-main {
        padding: 16px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .action-btn {
        min-width: auto;
    }
    
    .modal-content {
        margin: 0;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .nav-item span {
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1rem;
    }
    
    .summary-card {
        padding: 16px;
    }
    
    .summary-card i {
        font-size: 1.5rem;
    }
    
    .card-content span {
        font-size: 1.2rem;
    }
    
    .meta-card {
        padding: 16px;
    }
    
    .meta-actions {
        flex-direction: column;
        gap: 4px;
    }
    
    .bottom-nav {
        height: 60px;
    }
    
    :root {
        --bottom-nav-height: 60px;
    }
    
    .nav-item {
        padding: 4px 8px;
        min-width: 50px;
    }
    
    .nav-item i {
        font-size: 1rem;
    }
    
    .nav-item span {
        font-size: 0.6rem;
    }
}

.celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    z-index: 3000;
    pointer-events: none;
    animation: celebrate 2s ease-out forwards;
}

@keyframes celebrate {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

.completed-meta {
    border: 2px solid var(--success-color);
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(76, 175, 80, 0.05));
}

.completed-meta .progress-fill {
    background: var(--success-color);
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
