*,
*::before,
*::after {
box-sizing: border-box;
}

html {
scroll-behavior: smooth;
-webkit-text-size-adjust: 100%;
}

body,
h1,
h2,
h3,
h4,
p,
ul,
ol {
margin: 0;
}

img {
max-width: 100%;
display: block;
}

button,
input,
select,
textarea {
font: inherit;
}

:root {
--primary: #2563eb;
--primary-hover: #1d4ed8;
--success: #16a34a;
--danger: #dc2626;
--bg: #f8fafc;
--surface: #ffffff;
--text: #0f172a;
--muted: #64748b;
--border: #e2e8f0;
--shadow-sm: 0 1px 2px rgba(0,0,0,.05);
--shadow: 0 10px 25px rgba(15,23,42,.08);
--radius: 14px;
--container: 1200px;
}

[data-theme="dark"] {
--bg: #020617;
--surface: #0f172a;
--text: #f8fafc;
--muted: #94a3b8;
--border: #1e293b;
--shadow: 0 10px 30px rgba(0,0,0,.4);
}

body {
font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.6;
min-height: 100vh;
transition: background .3s ease, color .3s ease;
}

.container {
width: min(100% - 2rem, var(--container));
margin-inline: auto;
}

.site-header {
background: var(--surface);
border-bottom: 1px solid var(--border);
position: sticky;
top: 0;
z-index: 100;
backdrop-filter: blur(12px);
box-shadow: var(--shadow-sm);
}

.site-header .container {
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
padding: 1rem 0;
}

.site-header h1 {
font-size: clamp(1.5rem, 2vw, 2rem);
font-weight: 800;
}

.header-actions {
display: flex;
flex-wrap: wrap;
gap: .75rem;
}

button {
border: 0;
cursor: pointer;
padding: .75rem 1rem;
border-radius: 10px;
font-weight: 600;
transition: .2s ease;
}

button:hover {
transform: translateY(-1px);
}

#darkModeBtn,
#printBtn,
#shareBtn {
background: var(--primary);
color: white;
}

#darkModeBtn:hover,
#printBtn:hover,
#shareBtn:hover {
background: var(--primary-hover);
}

.calculator-section,
.faq-section {
padding: 3rem 0;
}

.calculator-section h2,
.faq-section h2 {
font-size: clamp(1.6rem, 3vw, 2.2rem);
margin-bottom: 1.5rem;
font-weight: 800;
}

.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 1.5rem;
box-shadow: var(--shadow);
margin-bottom: 1.5rem;
}

.results-card {
background: linear-gradient(135deg, var(--primary), #3b82f6);
color: white;
padding: 2rem;
border-radius: var(--radius);
text-align: center;
margin-top: 1.5rem;
}

.results-card h3 {
margin-bottom: 1rem;
}

.grid {
display: grid;
gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.input-group {
display: flex;
flex-direction: column;
gap: .5rem;
}

label {
font-size: .95rem;
font-weight: 600;
}

input,
select {
width: 100%;
min-height: 48px;
padding: .85rem 1rem;
border: 1px solid var(--border);
border-radius: 10px;
background: var(--surface);
color: var(--text);
transition: .2s ease;
}

input:focus,
select:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}

#monthlyPayment {
font-size: clamp(2rem, 5vw, 4rem);
font-weight: 800;
margin-top: .5rem;
}

.summary-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
gap: 1rem;
margin-top: 2rem;
}

.summary-grid div {
background: rgba(255,255,255,.15);
padding: 1rem;
border-radius: 12px;
}

.summary-grid span {
display: block;
opacity: .9;
font-size: .9rem;
}

.summary-grid strong {
display: block;
margin-top: .4rem;
font-size: 1.2rem;
}

.comparison-grid {
display: grid;
gap: 1.5rem;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

canvas {
width: 100% !important;
height: auto !important;
min-height: 350px;
}

.table-wrapper {
overflow-x: auto;
background: var(--surface);
border-radius: var(--radius);
border: 1px solid var(--border);
box-shadow: var(--shadow);
}

table {
width: 100%;
border-collapse: collapse;
min-width: 900px;
}

thead {
background: var(--primary);
color: white;
}

th,
td {
padding: 1rem;
text-align: left;
border-bottom: 1px solid var(--border);
}

tbody tr:hover {
background: rgba(37,99,235,.05);
}

details {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
margin-bottom: 1rem;
overflow: hidden;
}

summary {
padding: 1rem;
cursor: pointer;
font-weight: 700;
}

details p {
padding: 0 1rem 1rem;
}

.site-footer {
margin-top: 3rem;
border-top: 1px solid var(--border);
background: var(--surface);
}

.site-footer .container {
padding: 2rem 0;
text-align: center;
color: var(--muted);
}

.skeleton {
background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
background-size: 200% 100%;
animation: loading 1.2s infinite;
}

@keyframes loading {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.hidden { display: none; }

@media (max-width: 768px) {
.site-header .container {
flex-direction: column;
align-items: stretch;
}
.header-actions {
justify-content: center;
}
.results-card {
padding: 1.5rem;
}
#monthlyPayment {
font-size: 2.4rem;
}
}

@media (min-width: 1400px) {
.container {
max-width: 1320px;
}
}

@media print {
body { background: white; }
.site-header,
.header-actions,
button { display: none !important; }
.card,
.results-card {
box-shadow: none;
border: 1px solid #ccc;
}
.calculator-section {
page-break-inside: avoid;
}
}

@media (prefers-reduced-motion: reduce) {
* {
animation: none;
transition: none;
scroll-behavior: auto;
}
}
/* Navigation Links */
.nav-link {
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    padding: 0.5rem 1rem;
    transition: color 0.2s;
}
.nav-link:hover { color: var(--primary); }

/* Blog Section */
.blog-section { padding: 4rem 0; background: var(--bg); }
.blog-post h3 { font-size: 1.5rem; color: var(--primary); margin-bottom: 0.5rem; }
.blog-post p { margin-bottom: 1rem; color: var(--text); opacity: 0.9; }

/* Footer Layout */
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
    text-align: left;
}
.footer-col h4 { margin-bottom: 1rem; font-size: 1.1rem; }
.footer-col a {
    display: block;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: 0.2s ease;
}
.footer-col a:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 1.5rem; }

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 1rem 0;
    transform: translateY(100%);
    transition: transform 0.4s ease;
}
.cookie-banner:not(.hidden) { transform: translateY(0); }
.cookie-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}
.cookie-banner p { flex: 1; font-size: 0.9rem; margin: 0; min-width: 250px; }
.cookie-actions { display: flex; gap: 1rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-content {
    width: 90%; max-width: 600px;
    max-height: 80vh; overflow-y: auto;
    position: relative;
    padding: 2rem;
}
.close-modal {
    position: absolute;
    top: 1rem; right: 1rem;
    background: var(--bg);
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.2rem 0.6rem;
}