/* ── eCalc Public Calculator ─────────────────────────────────────────────── */

.ecalc-page {
    padding-top: calc(var(--header-height) + 24px);
    padding-bottom: 60px;
    min-height: 100vh;
}

.ecalc-hero {
    margin-bottom: 32px;
}
.ecalc-hero h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
}
.ecalc-hero__sub {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 600px;
}

/* ── Layout ────────────────────────────────────────────────────────────── */

.ecalc-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 28px;
    align-items: start;
}

.ecalc-results__sticky {
    position: sticky;
    top: calc(var(--header-height) + 16px);
}

/* ── Component blocks ──────────────────────────────────────────────────── */

.ecalc-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.ecalc-block:focus-within {
    border-color: var(--accent);
}
.ecalc-block--optional {
    opacity: 0.7;
    transition: opacity 0.2s;
}
.ecalc-block--optional:focus-within,
.ecalc-block--optional:hover {
    opacity: 1;
}

.ecalc-block__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.ecalc-block__header svg {
    width: 18px; height: 18px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.ecalc-block__header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}
.ecalc-block__opt-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-left: auto;
    font-style: italic;
}

.ecalc-block__info {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-family: var(--font-mono);
    min-height: 1.2em;
}

.ecalc-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ecalc-unit {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Link type toggle ──────────────────────────────────────────────────── */

.ecalc-link-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.ecalc-link-opt {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    transition: all 0.15s;
    flex: 1;
    justify-content: center;
}
.ecalc-link-opt input { display: none; }
.ecalc-link-opt:hover { border-color: var(--accent); color: var(--text-primary); }
.ecalc-link-opt--active {
    border-color: var(--accent);
    background: rgba(245, 158, 11, 0.08);
    color: var(--accent);
}

/* ── Form actions ──────────────────────────────────────────────────────── */

.ecalc-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* ── Results panel ─────────────────────────────────────────────────────── */

.ecalc-results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.ecalc-results__sticky {
    padding: 20px;
}

.ecalc-results__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

/* ── Metrics ───────────────────────────────────────────────────────────── */

.ecalc-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.ecalc-metric--large {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}
.ecalc-metric__label {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.ecalc-metric__value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 1.2;
    margin-bottom: 8px;
}

/* ── Gauge bars ────────────────────────────────────────────────────────── */

.ecalc-gauge {
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    overflow: hidden;
}
.ecalc-gauge__fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s, background 0.4s;
    width: 0;
}
.ecalc-gauge__scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ── Grid cells ────────────────────────────────────────────────────────── */

.ecalc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}
.ecalc-cell {
    padding: 10px 12px;
    background: var(--bg-card);
}
.ecalc-cell__label {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.ecalc-cell__value {
    display: block;
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* ── Charts ────────────────────────────────────────────────────────────── */

.ecalc-chart-section {
    margin-bottom: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.ecalc-chart-section h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}
.ecalc-chart-section canvas {
    width: 100%;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius);
}

/* ── Warnings ──────────────────────────────────────────────────────────── */

.ecalc-warnings:empty { display: none; }
.ecalc-warnings {
    margin-bottom: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.ecalc-warn {
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    margin-bottom: 6px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.ecalc-warn__icon {
    font-weight: 700;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}
.ecalc-warn--danger  { background: rgba(239,68,68,0.1); color: #f87171; }
.ecalc-warn--warning { background: rgba(245,158,11,0.1); color: #fbbf24; }
.ecalc-warn--info    { background: rgba(59,130,246,0.1); color: #60a5fa; }

/* ── Cost table ────────────────────────────────────────────────────────── */

.ecalc-cost {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.ecalc-cost h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}
.ecalc-cost table {
    width: 100%;
    font-size: 0.8rem;
}
.ecalc-cost td {
    padding: 4px 0;
}
.ecalc-cost td:last-child {
    text-align: right;
    font-family: var(--font-mono);
}
.ecalc-cost tfoot td {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    font-size: 0.9rem;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
    .ecalc-layout {
        grid-template-columns: 1fr 360px;
    }
}

@media (max-width: 900px) {
    .ecalc-layout {
        grid-template-columns: 1fr;
    }
    .ecalc-results__sticky {
        position: static;
    }
}

@media (max-width: 480px) {
    .ecalc-hero h1 { font-size: 1.5rem; }
    .ecalc-metrics { grid-template-columns: 1fr; }
    .ecalc-link-toggle { flex-direction: column; }
    .ecalc-form-actions { flex-direction: column; }
}
