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

:root {
    --primary-color: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --secondary-color: #0284c7;
    --accent-color: #0ea5e9;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --background: #f0f9ff;
    --background-secondary: #e0f2fe;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #cbd5e1;
    --border-light: #e2e8f0;
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-900: #1e3a8a;
    --shadow: 0 1px 3px 0 rgb(30 64 175 / 0.08), 0 1px 2px -1px rgb(30 64 175 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(30 64 175 / 0.12), 0 4px 6px -4px rgb(30 64 175 / 0.08);
    --shadow-xl: 0 20px 25px -5px rgb(30 64 175 / 0.15), 0 8px 10px -6px rgb(30 64 175 / 0.1);
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e40af 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(14, 165, 233, 0.15) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

header h1 {
    font-size: 2.8rem;
    margin-bottom: 12px;
    font-weight: 700;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.5px;
    color: #ffffff;
}

.subtitle {
    font-size: 1.15rem;
    opacity: 0.92;
    color: #e0f2fe;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    align-items: start;
}

.input-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}


.results-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-xl);
    border-color: var(--blue-200);
}

.card h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--blue-100);
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: var(--blue-50);
}

.cost-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
}

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

.cost-name {
    grid-column: 1;
}

.cost-amount {
    grid-column: 2;
}

.btn-remove {
    grid-column: 3;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 36px;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.btn-add {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-add:hover {
    background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

.btn-primary,
.btn-secondary {
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 64, 175, 0.35);
}

.btn-secondary {
    background: var(--blue-50);
    color: var(--primary-color);
    border: 2px solid var(--blue-200);
}

.btn-secondary:hover {
    background: var(--blue-100);
    border-color: var(--primary-light);
    color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.metric-card {
    background: linear-gradient(135deg, var(--blue-50) 0%, #ffffff 100%);
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid var(--primary-color);
    border: 1px solid var(--blue-100);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, transparent 100%);
    border-radius: 0 0 0 100%;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(30, 64, 175, 0.15);
    border-color: var(--blue-200);
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.metric-value.profit {
    color: var(--success-color);
}

.metric-value.loss {
    color: var(--danger-color);
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

canvas {
    max-height: 300px;
    margin-top: 10px;
}

#scenariosList {
    max-height: 300px;
    overflow-y: auto;
}

.scenario-item {
    background: var(--blue-50);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    border: 1px solid var(--blue-100);
}

.scenario-item:hover {
    background: var(--blue-100);
    transform: translateX(4px);
    border-color: var(--blue-200);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.scenario-name {
    font-weight: 600;
    color: var(--primary-dark);
}

.scenario-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.scenario-buttons {
    display: flex;
    gap: 8px;
}

.btn-load,
.btn-delete {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn-load {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    color: white;
}

.btn-load:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
}

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

.btn-delete:hover {
    background: #dc2626;
}

#riskAnalysis {
    line-height: 1.8;
}

.risk-item {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.risk-low {
    background: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
    border-left: 4px solid var(--success-color);
    border: 1px solid #a7f3d0;
}

.risk-medium {
    background: linear-gradient(135deg, #fef3c7 0%, #fef9e7 100%);
    border-left: 4px solid var(--warning-color);
    border: 1px solid #fde68a;
}

.risk-high {
    background: linear-gradient(135deg, #fee2e2 0%, #fef2f2 100%);
    border-left: 4px solid var(--danger-color);
    border: 1px solid #fecaca;
}

.risk-icon {
    font-size: 1.5rem;
}

.risk-content {
    flex: 1;
}

.risk-title {
    font-weight: 600;
    margin-bottom: 4px;
}

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

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .cost-item {
        grid-template-columns: 1fr;
    }

    .btn-remove {
        width: 100%;
    }
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.calculating {
    animation: pulse 1.5s ease-in-out infinite;
}
