.calculator-page {
    background: var(--bg);
}

.calculator-hero {
    padding-bottom: 54px;
}

.calculator-hero .container {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 430px);
}

.calc-hero-panel {
    display: grid;
    gap: 14px;
    background: #0f1a16;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow);
}

.calc-hero-panel div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.calc-hero-panel div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.calc-hero-panel span {
    color: #c7d1cc;
    font-size: 14px;
    line-height: 1.5;
}

.calc-hero-panel strong {
    color: #fff;
    font-size: clamp(24px, 4vw, 36px);
    line-height: 1;
    white-space: nowrap;
}

.calculator-workspace {
    padding-top: 64px;
}

.calc-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 28px;
    align-items: start;
    min-width: 0;
}

.calc-summary {
    position: sticky;
    top: 96px;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.calc-summary h2 {
    font-size: 24px;
    margin-bottom: 18px;
}

.summary-metric {
    border-top: 1px solid var(--line);
    padding: 16px 0;
}

.summary-metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.summary-metric strong {
    display: block;
    color: var(--ink);
    font-size: 28px;
    line-height: 1;
}

.summary-metric.accent strong {
    color: var(--orange);
}

.summary-metric.danger strong {
    color: #c62828;
}

.summary-actions {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

.summary-actions .btn {
    justify-content: center;
}

.calc-sections {
    display: grid;
    gap: 22px;
    min-width: 0;
}

.calc-card {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow-sm);
}

.calc-card-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.calc-card-heading span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    background: var(--mint);
    color: var(--green);
    font-size: 14px;
    font-weight: 800;
    flex: 0 0 auto;
}

.calc-card-heading h2 {
    font-size: clamp(20px, 2.2vw, 26px);
    line-height: 1.25;
    margin: 0;
}

.calc-card-heading em {
    margin-left: auto;
    background: #0f1a16;
    color: #fff;
    border-radius: 999px;
    padding: 5px 10px;
    font-style: normal;
    font-size: 12px;
    font-weight: 800;
}

.calc-input-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.calc-input,
.calc-display {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.calc-input span,
.calc-display span {
    color: #33413c;
    font-size: 14px;
    font-weight: 800;
}

.calc-input input,
.package-row input,
.verify-inputs input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfdfc;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    padding: 12px 12px;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.calc-input input:focus,
.package-row input:focus,
.verify-inputs input:focus {
    border-color: rgba(20, 121, 91, 0.65);
    box-shadow: 0 0 0 3px rgba(20, 121, 91, 0.12);
    background: #fff;
}

.calc-input small,
.calc-display small,
.metric-tile small,
.result-tile small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.range-input {
    align-content: start;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
}

.range-row input[type="range"] {
    accent-color: var(--green);
}

.range-row strong {
    min-width: 48px;
    color: var(--green);
    text-align: right;
}

.calc-display {
    border: 1px solid rgba(20, 121, 91, 0.22);
    border-radius: var(--radius);
    background: rgba(223, 242, 234, 0.58);
    padding: 14px;
}

.calc-display strong {
    color: var(--green);
    font-size: 24px;
    line-height: 1;
}

.package-table {
    display: grid;
    gap: 10px;
}

.package-header,
.package-row {
    display: grid;
    grid-template-columns: 1.2fr repeat(4, minmax(90px, 1fr));
    gap: 10px;
    align-items: center;
}

.package-header {
    color: var(--green);
    font-size: 13px;
    font-weight: 800;
    padding: 0 2px;
}

.package-row {
    background: #f8fbf9;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
}

.package-row strong {
    color: var(--orange);
    text-align: right;
    white-space: nowrap;
}

.package-total {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
    border-top: 2px solid var(--mint);
    padding-top: 16px;
    margin-top: 4px;
}

.package-total span {
    margin-right: auto;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.package-total strong {
    color: var(--green);
    font-size: 18px;
}

.metric-grid {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.metric-grid.three {
    grid-template-columns: repeat(3, 1fr);
}

.metric-grid.four {
    grid-template-columns: repeat(4, 1fr);
}

.metric-tile,
.result-tile {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    background: #fbfdfc;
}

.metric-tile {
    border-width: 2px;
}

.metric-tile span,
.result-tile span {
    display: block;
    color: #44534e;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 8px;
}

.metric-tile strong,
.result-tile strong {
    display: block;
    color: var(--ink);
    font-size: clamp(22px, 3vw, 30px);
    line-height: 1;
    margin-bottom: 8px;
    word-break: keep-all;
}

.metric-tile.revenue {
    border-color: rgba(224, 100, 26, 0.35);
    background: #fff7f1;
}

.metric-tile.revenue strong {
    color: var(--orange);
}

.metric-tile.consumption {
    border-color: rgba(20, 121, 91, 0.35);
    background: #eff8f4;
}

.metric-tile.consumption strong,
.result-tile.safe strong {
    color: var(--green);
}

.metric-tile.debt,
.metric-tile.profit {
    border-color: rgba(37, 99, 235, 0.24);
    background: #f1f6ff;
}

.metric-tile.debt strong,
.metric-tile.profit strong {
    color: #1f5fbf;
}

.result-tile.accent strong {
    color: var(--orange);
}

.progress-block {
    margin: 22px 0 6px;
}

.progress-label,
.gap-bar-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #44534e;
    font-size: 13px;
    font-weight: 800;
}

.gap-bar {
    margin-top: 10px;
    background: #e8eeeb;
    border-radius: var(--radius);
    height: 34px;
    overflow: hidden;
}

.gap-bar-inner {
    width: 0;
    min-width: 42px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    background: linear-gradient(90deg, #f44336, #ff9800);
    transition: width 0.35s ease, background 0.2s ease;
    white-space: nowrap;
}

.gap-bar-label {
    color: var(--muted);
    font-size: 12px;
    margin-top: 7px;
    font-weight: 700;
}

.risk-alert {
    border-left: 4px solid #ff9800;
    border-radius: var(--radius);
    background: #fff7ec;
    color: #9a4d00;
    line-height: 1.75;
    margin-top: 18px;
    padding: 14px 16px;
    font-size: 14px;
}

.risk-alert.safe {
    background: #eaf7f0;
    border-left-color: var(--green);
    color: #176244;
}

.risk-alert.danger {
    background: #fff0f0;
    border-left-color: #c62828;
    color: #a61d1d;
}

.verify-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 18px;
}

.verify-inputs,
.verify-output {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    background: #fbfdfc;
}

.verify-inputs h3,
.verify-output h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.verify-inputs label {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) 52px;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.verify-inputs label:last-child {
    margin-bottom: 0;
}

.verify-inputs span {
    color: #44534e;
    font-size: 14px;
    font-weight: 800;
}

.verify-output {
    border-color: rgba(20, 121, 91, 0.32);
}

.verify-output div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
}

.verify-output div:last-child {
    border-bottom: 0;
    font-size: 18px;
    font-weight: 800;
}

.verify-output span {
    color: var(--muted);
}

.verify-output strong {
    white-space: nowrap;
}

.verify-output .positive {
    color: var(--green);
}

.verify-output .negative {
    color: #c62828;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.detail-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    background: #fff;
}

.detail-table th,
.detail-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
}

.detail-table th {
    color: var(--green);
    background: var(--mint);
    font-size: 13px;
}

.detail-table td {
    color: #3f4e48;
    font-size: 14px;
    line-height: 1.55;
}

.detail-table td:last-child,
.detail-table th:last-child {
    text-align: right;
    font-weight: 800;
    white-space: nowrap;
}

.detail-table tr:last-child td {
    border-bottom: 0;
}

.detail-table .row-revenue td {
    background: #fff7f1;
    color: #a9480e;
}

.detail-table .row-profit td {
    background: #eff8f4;
    color: #176244;
}

.detail-table .row-total td {
    background: #fffce8;
    color: #8b5c00;
    font-weight: 800;
}

@media (max-width: 1100px) {
    .calc-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .calc-summary {
        position: static;
    }

    .summary-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .calc-input-grid,
    .metric-grid.three,
    .metric-grid.four,
    .verify-grid {
        grid-template-columns: 1fr;
    }

    .package-header {
        display: none;
    }

    .package-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .package-row strong {
        text-align: left;
    }
}

@media (max-width: 768px) {
    .calculator-hero .container {
        grid-template-columns: 1fr;
    }

    .calc-card {
        padding: 22px;
    }

    .calc-card-heading {
        align-items: flex-start;
    }

    .calc-card-heading em {
        margin-left: 0;
    }

    .summary-actions,
    .verify-inputs label {
        grid-template-columns: 1fr;
    }

    .package-row {
        grid-template-columns: 1fr;
    }

    .package-total {
        justify-content: flex-start;
    }

    .package-total span {
        width: 100%;
        margin-right: 0;
    }

    .progress-label,
    .gap-bar-label {
        flex-direction: column;
    }
}
