:root {
    --blue: #007AFF;
    --blue-dark: #005BBB;
    --blue-light: rgba(0, 122, 255, 0.08);
    --bg: #f5f5f5;
    --card: #ffffff;
    --border: #e0e0e0;
    --text: #1a1a1a;
    --text-muted: #666;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Nav ── */
nav {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 32px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

nav .brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--blue);
    text-decoration: none;
    letter-spacing: -0.3px;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

nav a:hover, nav a.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

/* ── Page wrapper ── */
.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

/* ── Hero ── */
.hero {
    margin-bottom: 48px;
}

.hero h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 10px;
}

.hero p {
    color: var(--text-muted);
    font-size: 16px;
    max-width: 560px;
    line-height: 1.6;
}

/* ── Calculator cards ── */
.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 48px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
    display: block;
}

.card:hover {
    box-shadow: var(--shadow);
    border-color: var(--blue);
    transform: translateY(-1px);
}

.card-icon {
    font-size: 26px;
    margin-bottom: 12px;
}

.card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.card .tag {
    display: inline-block;
    margin-top: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--blue);
    background: var(--blue-light);
    border-radius: 4px;
    padding: 2px 7px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ── Calculator page layout ── */
.calc-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 36px 24px 80px;
}

.calc-page h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.calc-page .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 28px;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab-btn.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Formula box ── */
.formula-box {
    background: var(--blue-light);
    border-left: 4px solid var(--blue);
    border-radius: 0 8px 8px 0;
    padding: 18px 20px;
    margin-bottom: 24px;
}

.formula-box .formula-title {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--blue);
    margin-bottom: 12px;
}

.formula-box .formula-item {
    margin: 10px 0;
    font-size: 15px;
    line-height: 1.7;
}

/* ── Inputs ── */
.input-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    align-items: center;
    margin-bottom: 14px;
    gap: 10px;
}

.input-group:last-child { margin-bottom: 0; }

label {
    min-width: 200px;
    font-weight: 600;
    font-size: 14px;
}

input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    width: 110px;
    transition: border-color 0.15s;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.12);
}

.unit {
    font-size: 13px;
    color: var(--text-muted);
    min-width: 50px;
}

/* ── Button ── */
.btn {
    background: var(--blue);
    color: white;
    padding: 10px 24px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s;
    margin: 18px 0 4px;
}

.btn:hover { background: var(--blue-dark); }

/* ── Results ── */
.results-box {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-top: 16px;
}

.results-box h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 14px;
    font-weight: 700;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.result-row:last-child { border-bottom: none; }

.result-label { color: var(--text-muted); }
.result-value { font-weight: 700; font-size: 16px; color: var(--text); }

.highlight-box {
    background: var(--blue-light);
    border-left: 4px solid var(--blue);
    border-radius: 0 8px 8px 0;
    padding: 14px 18px;
    margin-top: 16px;
}

.highlight-box .result-row { border-bottom-color: rgba(0,122,255,0.15); }

/* ── Chart ── */
.chart-wrap {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
    position: relative;
    height: 440px;
}

/* ── Error ── */
.error { color: #d32f2f; font-weight: 600; font-size: 14px; }

/* ── Back link ── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 20px;
    transition: color 0.15s;
}
.back-link:hover { color: var(--blue); }
