/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: rgba(20, 20, 50, 0.7);
    --bg-card-hover: rgba(30, 30, 65, 0.8);
    --bg-input: rgba(255,255,255,0.05);
    --border: rgba(255,255,255,0.08);
    --border-focus: rgba(139,92,246,0.5);
    --text-primary: #f0f0ff;
    --text-secondary: #9898c8;
    --text-muted: #6868a0;
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-glow: rgba(139,92,246,0.3);
    --green: #10b981;
    --green-bg: rgba(16,185,129,0.12);
    --red: #ef4444;
    --red-bg: rgba(239,68,68,0.12);
    --blue: #3b82f6;
    --blue-bg: rgba(59,130,246,0.12);
    --amber: #f59e0b;
    --amber-bg: rgba(245,158,11,0.12);
    --rose: #f43f5e;
    --rose-bg: rgba(244,63,94,0.12);
    --violet: #8b5cf6;
    --violet-bg: rgba(139,92,246,0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="light"] {
    --bg-primary: #f5f5ff; --bg-secondary: #eeeef8;
    --bg-card: rgba(255,255,255,0.85); --bg-card-hover: rgba(255,255,255,0.95);
    --bg-input: rgba(0,0,0,0.04); --border: rgba(0,0,0,0.08);
    --text-primary: #1a1a2e; --text-secondary: #555580; --text-muted: #8888aa;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; min-height: 100vh; overflow-x: hidden; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* ===== Background ===== */
.bg-effects { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.glow { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.15; animation: floatGlow 20s ease-in-out infinite; }
.glow-1 { width: 600px; height: 600px; background: #8b5cf6; top: -200px; left: -100px; }
.glow-2 { width: 500px; height: 500px; background: #3b82f6; bottom: -150px; right: -100px; animation-delay: -7s; }
.glow-3 { width: 400px; height: 400px; background: #10b981; top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -14s; }
@keyframes floatGlow { 0%,100%{transform:translate(0,0) scale(1)} 33%{transform:translate(30px,-30px) scale(1.1)} 66%{transform:translate(-20px,20px) scale(0.9)} }
[data-theme="light"] .bg-effects { opacity: 0.5; }

/* ===== Header ===== */
.header { position: sticky; top: 0; z-index: 100; background: rgba(10,10,26,0.8); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border); }
[data-theme="light"] .header { background: rgba(245,245,255,0.85); }
.header-inner { max-width: 1400px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(59,130,246,0.15)); display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); }
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; }
.logo-text span { color: var(--accent); }
.logo-subtitle { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; }
.header-actions { display: flex; gap: 8px; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); }
.btn-icon:hover { background: var(--accent-glow); color: var(--accent); border-color: var(--border-focus); }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ===== Main ===== */
.main { position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; padding: 0 24px 60px; }

/* ===== Hero ===== */
.hero { text-align: center; padding: 40px 0 32px; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px; border-radius: 100px; font-size: 12px; font-weight: 600; color: var(--accent-light); background: var(--violet-bg); border: 1px solid rgba(139,92,246,0.2); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 1px; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.8)} }
.hero-title { font-size: clamp(26px, 4.5vw, 40px); font-weight: 800; letter-spacing: -1.5px; line-height: 1.15; margin-bottom: 12px; }
.gradient-text { background: linear-gradient(135deg, #8b5cf6, #3b82f6, #10b981); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-desc { font-size: 15px; color: var(--text-secondary); max-width: 580px; margin: 0 auto; line-height: 1.7; }

/* ===== Top Grid (Balanced) ===== */
.top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }

/* ===== Panel ===== */
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.panel-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--accent), #6366f1); color: white; }
.panel-title { font-size: 17px; font-weight: 700; }
.panel-subtitle { font-size: 12px; color: var(--text-muted); }

/* ===== Form ===== */
.form-section { padding: 16px; margin-bottom: 12px; border-radius: var(--radius-sm); background: var(--bg-input); border: 1px solid var(--border); }
.client-section { border-color: rgba(139,92,246,0.2); background: rgba(139,92,246,0.04); }
.section-label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); margin-bottom: 12px; }
.section-num { width: 24px; height: 24px; border-radius: 7px; background: var(--accent); color: white; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.optional-badge { font-size: 9px; padding: 2px 7px; border-radius: 4px; background: var(--amber-bg); color: var(--amber); text-transform: uppercase; letter-spacing: 0.5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.input-wrap { display: flex; align-items: center; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 0 10px; transition: var(--transition); }
.input-wrap:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-wrap input { flex: 1; background: none; border: none; outline: none; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 500; padding: 9px 4px; width: 100%; min-width: 0; }
.input-wrap input[type="text"],
.input-wrap input[type="tel"],
.input-wrap input[type="email"] { font-family: 'Inter', sans-serif; font-size: 13px; }
.input-prefix, .input-suffix { font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.computed-value { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: var(--radius-xs); background: rgba(139,92,246,0.06); border: 1px dashed rgba(139,92,246,0.2); margin-top: 4px; }
.computed-value span:first-child { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.computed-amount { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; color: var(--accent-light); }
.computed-amount.accent { color: var(--amber); }
.computed-amount.success { color: var(--green); }
.computed-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sale-value { background: rgba(16,185,129,0.06); border-color: rgba(16,185,129,0.2); }

.btn-calculate { width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm); background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white; font-size: 14px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; transition: var(--transition); }
.btn-calculate:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--accent-glow); }
.btn-calculate:active { transform: translateY(0); }

/* ===== Results Summary Panel ===== */
.results-summary-panel { position: sticky; top: 80px; }
.placeholder-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 350px; text-align: center; gap: 12px; }
.placeholder-state h3 { font-size: 17px; color: var(--text-secondary); }
.placeholder-state p { font-size: 13px; color: var(--text-muted); max-width: 260px; }
.hidden { display: none !important; }

/* Gain Card */
.gain-card { text-align: center; padding: 24px 20px; border-radius: var(--radius); margin-bottom: 16px; }
.gain-card.positive { background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(16,185,129,0.05)); border: 1px solid rgba(16,185,129,0.2); }
.gain-card.negative { background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(239,68,68,0.05)); border: 1px solid rgba(239,68,68,0.2); }
.gain-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.gain-amount { font-family: 'JetBrains Mono', monospace; font-size: 32px; font-weight: 800; margin-bottom: 4px; }
.gain-card.positive .gain-amount { color: var(--green); }
.gain-card.negative .gain-amount { color: var(--red); }
.gain-percent { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.gain-annualized { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Summary Cards */
.summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.summary-card { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg-input); border: 1px solid var(--border); }
.summary-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.summary-icon.blue { background: var(--blue-bg); color: var(--blue); }
.summary-icon.green { background: var(--green-bg); color: var(--green); }
.summary-icon.amber { background: var(--amber-bg); color: var(--amber); }
.summary-icon.rose { background: var(--rose-bg); color: var(--rose); }
.summary-label { font-size: 10px; color: var(--text-muted); display: block; }
.summary-value { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; }

/* Breakdown */
.section-title-sm { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.breakdown-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden; }
.breakdown-card-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.breakdown-card-title { font-size: 13px; font-weight: 700; }
.breakdown-card-badge { font-size: 9px; font-weight: 700; padding: 3px 9px; border-radius: 100px; text-transform: uppercase; letter-spacing: 0.5px; }
.breakdown-card-badge.blue { background: var(--blue-bg); color: var(--blue); }
.breakdown-card-badge.amber { background: var(--amber-bg); color: var(--amber); }
.breakdown-card-badge.green { background: var(--green-bg); color: var(--green); }
.breakdown-card-badge.violet { background: var(--violet-bg); color: var(--violet); }
.breakdown-rows { padding: 2px 0; }
.breakdown-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 16px; font-size: 12px; }
.breakdown-row span:first-child { color: var(--text-secondary); }
.breakdown-row span:last-child { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 12px; }
.breakdown-row.highlight { background: rgba(139,92,246,0.05); font-weight: 700; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.breakdown-row.highlight span:first-child { color: var(--text-primary); font-weight: 700; }
.breakdown-row.big span { font-size: 14px !important; }
.final-card { border: 1px solid rgba(139,92,246,0.3); }

/* Comparison */
.comparison-section-inline { margin-top: 16px; }
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.comparison-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.loan-cmp { border-color: rgba(245,158,11,0.25); }
.cash-cmp { border-color: rgba(16,185,129,0.25); }
.cmp-header { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.cmp-badge { font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 100px; text-transform: uppercase; letter-spacing: 0.5px; }
.cmp-badge.amber { background: var(--amber-bg); color: var(--amber); }
.cmp-badge.green { background: var(--green-bg); color: var(--green); }
.cmp-rows { padding: 2px 0; }
.cmp-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 14px; font-size: 11px; }
.cmp-row span:first-child { color: var(--text-secondary); }
.cmp-row span:last-child { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 11px; }
.cmp-row.highlight { background: rgba(139,92,246,0.05); border-top: 1px solid var(--border); padding: 8px 14px; }
.cmp-row.highlight span:first-child { color: var(--text-primary); font-weight: 700; }
.comparison-verdict { margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; text-align: center; line-height: 1.6; background: linear-gradient(135deg, rgba(139,92,246,0.08), rgba(59,130,246,0.08)); border: 1px solid rgba(139,92,246,0.15); }

/* Download Button */
.btn-download { width: 100%; margin-top: 16px; padding: 14px; border: none; border-radius: var(--radius-sm); background: linear-gradient(135deg, #10b981, #059669); color: white; font-size: 14px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; transition: var(--transition); box-shadow: 0 4px 16px rgba(16,185,129,0.25); }
.btn-download:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(16,185,129,0.4); }
.btn-download:active { transform: translateY(0); }

/* ===== Detail Sections (Full Width) ===== */
.detail-sections { margin-top: 28px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-container { margin-top: 8px; }
canvas { width: 100% !important; max-height: 280px; }

/* Table */
.table-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.table-wrapper { overflow-x: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.amort-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.amort-table thead { background: var(--bg-input); }
.amort-table th { padding: 10px 12px; text-align: right; font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.amort-table th:first-child { text-align: center; }
.amort-table td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border); font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.amort-table td:first-child { text-align: center; font-weight: 700; color: var(--accent-light); }
.amort-table tbody tr:hover { background: var(--bg-card-hover); }

/* ===== Footer ===== */
.footer { text-align: center; padding: 24px; font-size: 13px; color: var(--text-muted); border-top: 1px solid var(--border); position: relative; z-index: 1; }
.footer-inner { max-width: 1400px; margin: 0 auto; }
.footer-brand { margin-top: 4px; font-size: 14px; font-weight: 600; }
.footer-brand a { color: var(--accent); text-decoration: none; transition: var(--transition); }
.footer-brand a:hover { color: var(--accent-light); text-decoration: underline; }

/* ===== Print ===== */
@media print {
    .bg-effects, .header, .hero, .btn-calculate, .btn-icon, .placeholder-state, .footer, .btn-download, .client-section { display: none !important; }
    body { background: white; color: #111; }
    .main { max-width: 100%; padding: 0; }
    .top-grid { display: block; }
    .input-panel { display: none !important; }
    .panel, .chart-section, .table-section { background: none; border: none; box-shadow: none; }
    .results-summary-panel { position: static; }
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .top-grid { grid-template-columns: 1fr; }
    .results-summary-panel { position: static; }
    .detail-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .form-row, .computed-row, .summary-cards, .comparison-grid { grid-template-columns: 1fr; }
    .hero-title { font-size: 24px; }
    .panel { padding: 16px; }
    .gain-amount { font-size: 26px; }
}

/* ===== Animations ===== */
@keyframes fadeInUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
.summary-content > * { animation: fadeInUp 0.4s ease forwards; }
.summary-content > *:nth-child(2) { animation-delay: 0.08s; }
.summary-content > *:nth-child(3) { animation-delay: 0.12s; }
.summary-content > *:nth-child(4) { animation-delay: 0.16s; }
.summary-content > *:nth-child(5) { animation-delay: 0.2s; }
