/* Practice finance and scan comparison tools ---------------------------------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.calc-grid { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 24px; align-items: start; }
.calc-stack { display: flex; flex-direction: column; gap: 24px; margin-bottom: 24px; }
.calc-panel, .calc-result, .calc-compare { padding: 26px; }
.calc-grid .calc-result { position: sticky; top: 20px; }
.calc-compare { margin-top: 24px; }
.calc-group { border: 0; border-top: 1px solid var(--line); margin: 20px 0 0; padding: 16px 0 0; display: grid; gap: 14px; }
.calc-group legend { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--teal-deep); padding-right: 10px; }
.calc-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 14px; }
.calc-group .calc-field, .calc-row .calc-field, .option-card .calc-field { margin-top: 0; }
.calc-field small { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.5; }
.calc-field > input, .calc-field > select, .calc-input input, .option-name { width: 100%; border: 1.5px solid var(--line); background: var(--paper); border-radius: 10px; padding: 10px 12px; color: var(--ink); font-size: 15px; font-weight: 500; transition: border-color .15s, box-shadow .15s; }
.calc-input { position: relative; display: flex; }
.calc-input input { padding-right: 64px; font-variant-numeric: tabular-nums; }
.calc-input em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12px; font-weight: 600; color: var(--muted); pointer-events: none; }
.calc-field input:focus, .calc-field select:focus, .option-name:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(31, 103, 184, .15); }
.calc-row { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 14px; align-items: end; }
.field-note { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi span { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi strong { font-size: 24px; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; overflow-wrap: anywhere; }
.kpi-main { grid-column: 1 / -1; background: linear-gradient(135deg, var(--navy), var(--navy-mid)); border-color: transparent; }
.kpi-main span { color: rgba(255, 255, 255, .72); }
.kpi-main strong { color: #fff; font-size: 44px; }
.kpi strong.negative, td.negative { color: var(--danger); }
.kpi-main strong.negative { color: #ffb4ab; }
[data-level=loss] { background: var(--danger-soft); color: var(--danger); }
[data-level=thin] { background: var(--warning-soft); color: var(--warning); }
[data-level=healthy] { background: var(--success-soft); color: var(--success); }

.cost-bar { display: flex; height: 18px; border-radius: var(--pill); overflow: hidden; background: var(--surface); gap: 2px; }
.cost-bar .seg { flex-basis: 0; min-width: 3px; }
.cost-legend { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12px; color: var(--text); }
.cost-legend li { display: flex; align-items: center; gap: 7px; }
.cost-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.seg-materials { background: #f59e0b; }
.seg-lab { background: #8b5cf6; }
.seg-other { background: #94a3b8; }
.seg-chair { background: var(--blue); }
.seg-clinician { background: var(--navy); }
.seg-payment { background: #ec4899; }
.seg-profit { background: var(--teal); }
.calc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 18px; }

.table-wrap { overflow-x: auto; position: relative; contain: inline-size; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.compare-table th, .compare-table td { text-align: right; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.compare-table th:first-child { text-align: left; white-space: normal; min-width: 160px; }
.compare-table thead th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.compare-table tbody th { font-weight: 600; color: var(--ink); }
.compare-table tr.best { background: var(--teal-soft); }
.compare-table tr.best th:after { content: 'Best'; margin-left: 8px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #fff; background: var(--teal-deep); border-radius: var(--pill); padding: 2px 8px; vertical-align: 2px; }
.compare-clear { margin-left: auto; }
.calc-compare .panel-heading .muted { font-size: 12px; }
.icon-button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; flex-shrink: 0; }
.icon-button:hover { color: var(--danger); border-color: #fecdca; background: var(--danger-soft); }
.icon-button[hidden] { display: none; }

.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.option-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; display: grid; gap: 12px; background: var(--bg); min-width: 0; }
.option-head { display: flex; align-items: center; gap: 10px; }
.option-letter { width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.option-name { font-weight: 600; }
.savings-line { margin: 18px 0 0; font-size: 15px; line-height: 1.6; color: var(--ink); font-weight: 500; }
.quality-note { display: flex; gap: 12px; margin-top: 18px; padding: 16px; border-radius: var(--radius); background: var(--warning-soft); border: 1px solid #fedf89; }
.quality-note .icon { width: 20px; height: 20px; color: var(--warning); flex-shrink: 0; margin-top: 2px; }
.quality-note strong { font-size: 14px; color: var(--ink); }
.quality-note p { font-size: 13px; line-height: 1.6; margin: 4px 0 0; }

.stl-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; align-items: start; }
.stl-drop { position: relative; display: flex; align-items: center; gap: 14px; padding: 16px; border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--bg); cursor: pointer; margin-bottom: 12px; transition: border-color .2s, background .2s; }
.stl-drop:hover, .stl-drop:focus-within { border-color: var(--blue); background: var(--blue-soft); }
.stl-drop.has-file { border-style: solid; border-color: var(--teal); background: var(--teal-soft); }
.stl-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.stl-drop .step-number { flex-shrink: 0; }
.stl-drop-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.stl-drop-copy strong { font-size: 14px; color: var(--ink); }
.stl-file { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.stl-drop > .icon { width: 20px; height: 20px; color: var(--navy); flex-shrink: 0; }
#stlForm .consent { margin: 8px 0 4px; }
.stl-toggle { margin-left: auto; }
.stl-viewport { position: relative; height: 520px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #f7f9fc; margin-bottom: 20px; }
.stl-viewport canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stl-viewport canvas:active { cursor: grabbing; }
.stl-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; pointer-events: none; padding: 16px; }
.stl-empty .icon { width: 54px; height: 54px; stroke-width: 1.1; color: var(--line-strong); margin-bottom: 10px; }
.stl-empty[hidden], .stl-scale[hidden], .kpi-grid[hidden] { display: none; }
.stl-scale { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 600; color: var(--ink); pointer-events: none; }
.stl-scale i { flex: 1; height: 10px; border-radius: var(--pill); background: linear-gradient(90deg, rgb(26, 77, 255), rgb(64, 191, 255) 40%, rgb(33, 168, 107) 40%, rgb(33, 168, 107) 60%, rgb(255, 217, 51) 60%, rgb(255, 38, 13)); box-shadow: var(--shadow); }
.stl-scale span { background: rgba(255, 255, 255, .9); padding: 2px 8px; border-radius: var(--pill); }

@media (max-width: 1100px) {
    .calc-grid, .stl-grid { grid-template-columns: 1fr; }
    .calc-grid .calc-result { position: static; }
    .calc-row { grid-template-columns: repeat(2, 1fr); }
    .calc-row .calc-field:first-child { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
    .calc-panel, .calc-result, .calc-compare { padding: 20px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .kpi strong { font-size: 20px; }
    .kpi-main strong { font-size: 34px; }
    .calc-row { grid-template-columns: 1fr; }
    .stl-viewport { height: 380px; }
    .compare-clear { margin-left: 0; }
}
@media print {
    .site-header, .lab-bar, .site-footer, .lab-promo, .lab-nudge, .breadcrumb, .calc-actions, .compare-clear, .icon-button { display: none !important; }
    .calc-grid, .stl-grid { grid-template-columns: 1fr; }
    .calc-grid .calc-result { position: static; }
    .panel { box-shadow: none; break-inside: avoid; }
    .kpi-main { background: none; border: 1px solid #000; }
    .kpi-main strong, .kpi-main span { color: #000; }
}
