:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --text: #171715;
  --muted: #6f706b;
  --line: #deded8;
  --strong-line: #c9c9c0;
  --accent: #1f4f42;
  --accent-soft: #e7f0ec;
  --danger: #a33a32;
  --warning: #875d12;
  --warning-bg: #fff7df;
  --success: #276448;
  --success-bg: #eaf5ef;
  --shadow: 0 8px 26px rgba(23, 23, 21, 0.06);
  --radius: 18px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-header,
.app-shell,
.app-footer { max-width: 1540px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.app-header { display: flex; align-items: center; gap: 10px; padding-top: 8px; padding-bottom: 8px; white-space: nowrap; overflow-x: auto; }
.app-header h1 { margin: 0; font-size: 16px; line-height: 1; letter-spacing: -0.02em; flex: 0 0 auto; }
h2 { margin: 3px 0 18px; font-size: 21px; letter-spacing: -0.02em; }
.subtitle { color: var(--muted); margin: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.eyebrow { display: inline-block; margin: 0; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-size: 10px; font-weight: 700; text-decoration: none; flex: 0 0 auto; }
.eyebrow:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.privacy-badge, .status-badge { background: var(--accent-soft); color: var(--accent); border: 1px solid #cfe0d8; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.app-header .privacy-badge { margin-left: auto; flex: 0 0 auto; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.scenario-bar { padding: 14px; display: flex; align-items: end; gap: 14px; justify-content: space-between; position: sticky; top: 8px; z-index: 20; }
.scenario-controls { display: flex; align-items: end; gap: 12px; min-width: 0; }
.scenario-select-wrap { min-width: 220px; }
.scenario-bar .current-period-control { margin: 0; justify-content: flex-start; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar-more { position: relative; }
.toolbar-more > summary { list-style: none; cursor: pointer; border: 1px solid var(--strong-line); border-radius: 9px; padding: 8px 12px; min-height: 36px; font-size: 13px; font-weight: 700; }
.toolbar-more > summary::-webkit-details-marker { display: none; }
.toolbar-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; display: grid; gap: 4px; min-width: 190px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.toolbar-menu .button { width: 100%; display: flex; align-items: center; justify-content: flex-start; text-align: left; white-space: nowrap; }
.toolbar-menu .file-button { cursor: pointer; }
.mode-tabs, .result-tabs { display: flex; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin: 12px 0; width: fit-content; }
.mode-tabs button, .result-tabs button { border: 0; border-radius: 8px; padding: 10px 16px; background: transparent; color: var(--muted); font-weight: 740; cursor: pointer; }
.mode-tabs button[aria-selected="true"], .result-tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.mode-tabs button:focus-visible, .result-tabs button:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid #73a897; outline-offset: 2px; }
.product-step, .whatif-panel { padding: 17px; }
.product-step h2 { margin-bottom: 8px; }
.product-list { display: grid; gap: 9px; }
.product-row { display: grid; grid-template-columns: minmax(150px,1fr) minmax(150px,.8fr) minmax(100px,.5fr) auto; gap: 9px; align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.product-advanced summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 10px 0; }
.product-advanced label { min-width: 120px; }
.product-subtotal { margin: 12px 0 0; font-weight: 780; }
.role-productivity { margin-top: 6px; }
.role-productivity summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.role-productivity label { display: block; margin-top: 7px; font-size: 11px; color: var(--muted); }
.whatif-panel { margin-bottom: 14px; }
.whatif-controls, .whatif-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0; }
.whatif-fields > label, .whatif-row > label { min-width: 180px; flex: 1; }
.whatif-row { display: flex; flex: 1 1 100%; gap: 10px; }
.distribution-tier { padding: 12px 0; border-top: 1px solid var(--line); }
.distribution-tier h3 { margin: 4px 0; }
.fund-row { display: grid; grid-template-columns: minmax(110px,1fr) minmax(110px,.8fr) minmax(130px,1fr) minmax(170px,1.2fr) minmax(100px,.7fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.fund-row > span { font-variant-numeric: tabular-nums; }
.fund-row small { color: var(--muted); }
.fund-enabled { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.distribution-summary, .reverse-result { display: grid; gap: 7px; padding: 14px; margin: 12px 0; border-radius: 12px; background: var(--surface-2); }
.waterfall { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin: 12px 0; }
.waterfall > div { min-height: 66px; padding: 10px; border-radius: 10px; background: linear-gradient(90deg,var(--accent-soft),#fff); border: 1px solid #cfe0d8; font-size: 12px; font-weight: 740; }
body.guided-current .workspace { display: flex; flex-direction: column; }
body.guided-current .inputs-column { display: flex; flex-direction: column; order: 1; width: 100%; }
body.guided-current #productStep { order: 1; }
body.guided-current #teamStep { order: 2; }
body.guided-current #expensesStep { order: 3; }
body.guided-current #taxStep { order: 4; }
body.guided-current .results-column { order: 5; width: 100%; }
.button { border: 1px solid var(--strong-line); background: var(--surface); color: var(--text); border-radius: 9px; padding: 8px 11px; min-height: 36px; font-size: 13px; font-weight: 650; }
.button:hover { border-color: #999a92; background: var(--surface-2); }
.button.primary { background: var(--text); color: #fff; border-color: var(--text); }
.button.add { margin-top: 12px; background: var(--accent-soft); color: var(--accent); border-color: #cfe0d8; }
.button.danger-ghost { color: var(--danger); }
.button:disabled { cursor: default; opacity: .52; }
.file-button input { display: none; }
.calculation-action { white-space: nowrap; font-weight: 760; }
.calculation-action.current:disabled { opacity: 1; cursor: default; border-color: #cae5d6; background: var(--success-bg); color: var(--success); }
.calculation-action.dirty { border-color: var(--text); background: var(--text); color: #fff; }

.summary-grid { display: grid; grid-template-columns: repeat(8, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px; min-height: 94px; }
.metric .label { color: var(--muted); font-size: 12px; min-height: 34px; }
.metric .value { margin-top: 5px; font-size: 19px; font-weight: 780; letter-spacing: -0.03em; }
.metric .sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.metric.negative .value { color: var(--danger); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr); gap: 16px; align-items: start; }
.inputs-column, .results-column { display: grid; gap: 12px; }
.step { overflow: hidden; }
.step summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 15px 17px; cursor: pointer; font-weight: 760; }
.step summary::-webkit-details-marker { display: none; }
.step summary span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: var(--text); color: white; font-size: 12px; }
.step[open] summary { border-bottom: 1px solid var(--line); }
.step-body { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: #4f504c; font-size: 12px; font-weight: 680; }
input, select { width: 100%; background: #fff; color: var(--text); border: 1px solid var(--strong-line); border-radius: 9px; padding: 9px 10px; min-height: 39px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,79,66,.10); }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--accent); }
.toggle-row { display: flex; grid-template-columns: none; align-items: center; flex-direction: row; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.tax-note { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; color: var(--muted); font-size: 12px; }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.editor-table, .result-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.editor-table th, .editor-table td, .result-table th, .result-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.editor-table th, .result-table th { color: var(--muted); background: var(--surface-2); font-size: 11px; font-weight: 760; position: sticky; top: 0; }
.editor-table td { padding: 6px; }
.editor-table input, .editor-table select { min-width: 110px; padding: 7px 8px; min-height: 34px; font-size: 12px; }
.editor-table .name-input { min-width: 150px; }
.editor-actions { display: flex; gap: 5px; align-items: center; }
.icon-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--danger); }
.icon-button.duplicate { color: var(--accent); }
.icon-button:hover { background: var(--surface-2); border-color: var(--strong-line); }

.recalc-notice { display: flex; gap: 16px; justify-content: space-between; align-items: center; padding: 13px 14px; border: 1px solid #efdfa9; background: var(--warning-bg); color: var(--warning); border-radius: var(--radius-sm); font-size: 12px; }
.recalc-notice .button { flex: 0 0 auto; }
.summary-grid.is-stale .metric,
.results-column.is-stale .result-card { opacity: .58; transition: opacity .15s ease; }
.empty-results { grid-column: 1 / -1; padding: 16px; border: 1px dashed var(--strong-line); border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 13px; }

.result-card { padding: 17px; }
.result-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.result-table { min-width: 0; }
.result-table td:last-child, .result-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.result-table tr.total td { border-top: 2px solid var(--strong-line); font-weight: 800; }
.result-table tr.subtotal td { font-weight: 730; background: #fbfbf9; }
.result-table tr.negative td:last-child { color: var(--danger); }
.kpi-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi-item { background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 11px; }
.kpi-item .k { color: var(--muted); font-size: 11px; }
.kpi-item .v { font-size: 16px; font-weight: 760; margin-top: 4px; }
.team-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.team-row:last-child { border-bottom: 0; }
.team-row .muted { color: var(--muted); font-size: 12px; }
.editor-table .muted { max-width: 240px; font-size: 10px; line-height: 1.35; margin-top: 5px; }
.current-period-control { display: flex; justify-content: flex-end; margin: 0 0 -4px; }
.current-period-control label { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.current-period-control select { width: auto; min-width: 125px; min-height: 34px; }
.current-role-list { display: grid; gap: 9px; }
.current-role-card { display: grid; grid-template-columns: minmax(150px,1.4fr) minmax(115px,.8fr) minmax(150px,1fr) minmax(155px,1fr) auto; align-items: end; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.current-role-card label { min-width: 0; }
.current-role-card .role-actions { align-self: end; min-height: 39px; }
.current-role-card .role-productivity { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 8px; }
.role-productivity > summary { cursor: pointer; color: var(--accent); font-size: 12px; font-weight: 740; }
.role-productivity .hint { margin: 8px 0; }
.productivity-fields { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-top: 8px; }
.current-role-card:has([data-field="type"] option[value="manager"]:checked) .manager-parent { display: grid; }
.current-role-card .manager-parent { display: none; }
.current-role-card input { font-variant-numeric: tabular-nums; }
.current-period-control { order: 0; }
.current-only[data-bind="analysisMode"] { display: none !important; }
body.guided-current #expensesTable { min-width: 0; table-layout: fixed; }
body.guided-current #expensesTable th:nth-child(3), body.guided-current #expensesTable th:nth-child(5), body.guided-current #expensesTable td:nth-child(3), body.guided-current #expensesTable td:nth-child(5) { display: none; }
body.guided-current #expensesTable th:first-child, body.guided-current #expensesTable td:first-child { width: 22%; }
body.guided-current #expensesTable th:nth-child(2), body.guided-current #expensesTable td:nth-child(2) { width: 30%; }
body.guided-current #expensesTable th:nth-child(4), body.guided-current #expensesTable td:nth-child(4) { width: 32%; }
body.guided-current #expensesTable th:last-child, body.guided-current #expensesTable td:last-child { width: 16%; }
body.guided-current #expensesTable input, body.guided-current #expensesTable select { min-width: 0; width: 100%; }
.comparison-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.comparison-kpis > div { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.comparison-kpis span { color: var(--muted); font-size: 11px; }
.comparison-kpis strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.comparison-kpis .negative strong { color: var(--danger); }
.comparison-kpis .positive strong { color: var(--success); }
.comparison-table { min-width: 650px; font-size: 12px; margin-bottom: 12px; }
.comparison-table th:not(:first-child), .comparison-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.comparison-table tr.negative td:last-child { color: var(--danger); font-weight: 760; }
.result-card #employmentComparison > h2 { margin-bottom: 8px; }
.warning { padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; background: var(--warning-bg); border: 1px solid #efdfa9; color: var(--warning); font-size: 12px; }
.warning.error { color: var(--danger); background: #fff0ee; border-color: #f0cac6; }
.warning.ok { color: var(--success); background: var(--success-bg); border-color: #cae5d6; }
.warning:last-child { margin-bottom: 0; }
.chart-wrap { position: relative; width: 100%; min-height: 280px; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-empty { display: grid; min-height: 240px; place-items: center; padding: 18px; border: 1px dashed var(--strong-line); border-radius: 10px; background: var(--surface-2); color: var(--muted); text-align: center; font-size: 13px; }
.chart-label { fill: #6f706b; font-size: 10px; }
.chart-axis { stroke: #c8c8c1; stroke-width: 1; }
.chart-axis-tick { stroke: #c8c8c1; stroke-width: 1; }
.chart-profit { fill: none; stroke: #1f4f42; stroke-width: 2.5; }
.chart-zero { stroke: #9b9c95; stroke-dasharray: 4 4; }
.chart-target { stroke: #875d12; stroke-dasharray: 5 5; }
.chart-step { stroke: #d3d3cc; stroke-dasharray: 2 5; }
.chart-point { fill: #171715; }
.chart-target-point { fill: #b07b18; stroke: #fff; stroke-width: 2; }
.chart-hit { fill: transparent; stroke: transparent; cursor: pointer; }
.chart-hit:hover, .chart-hit:focus-visible { fill: rgba(31,79,66,.1); stroke: var(--accent); stroke-width: 1; outline: none; }
.chart-marker { pointer-events: none; }
.chart-marker.chart-point { fill: #171715; stroke: #fff; stroke-width: 2; }
.chart-marker.chart-target-point { fill: #b07b18; stroke: #fff; stroke-width: 2; }
.chart-marker.chart-break-even-point { fill: #fff; stroke: #a33a32; stroke-width: 3; }
.chart-break-even-label { fill: #a33a32; font-weight: 750; }
.chart-tooltip, .annual-chart-tooltip { padding: 10px 12px; margin: 8px 0; border: 1px solid var(--strong-line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); font-size: 12px; line-height: 1.55; }
.chart-tooltip { position: absolute; z-index: 5; box-sizing: border-box; width: max-content; max-width: min(280px, calc(100% - 16px)); max-height: calc(100% - 16px); overflow: auto; margin: 0; pointer-events: none; }
.chart-tooltip-below { box-shadow: 0 3px 12px rgba(0,0,0,.12); }
.chart-break-even-reason { margin-top: 8px; }
.tax-timeline { margin-bottom: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.tax-timeline h3 { margin: 0 0 9px; font-size: 14px; }
.timeline-event { display: grid; grid-template-columns: 100px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.timeline-event:last-of-type { border-bottom: 0; }
.tax-timeline details { margin-top: 10px; }
.tax-timeline details > summary { cursor: pointer; color: var(--accent); font-size: 12px; font-weight: 750; }
.month-detail { margin-top: 8px; min-width: 1000px; font-size: 11px; }
.month-detail th, .month-detail td { padding: 7px 5px; }

.annual-config { margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.annual-collapsible > summary { cursor: pointer; color: var(--accent); font-weight: 760; }
.annual-collapsible[open] > summary { margin-bottom: 12px; }
.annual-config h3, .annual-chart h3 { margin: 0 0 8px; }
.annual-config select { display: block; margin-top: 5px; }
.annual-month-inputs { display: grid; grid-template-columns: repeat(6,minmax(70px,1fr)); gap: 8px; }
.annual-month-inputs label, .annual-availability td { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.annual-month-inputs input, .annual-availability input { width: 100%; min-width: 52px; padding: 6px; }
.annual-availability { min-width: 950px; font-size: 12px; }
.annual-availability th:first-child { min-width: 150px; text-align: left; }
.annual-kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; margin: 16px 0; }
.annual-kpis .metric { min-width: 0; }
.annual-chart { margin: 18px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.annual-chart svg { display: block; width: 100%; min-width: 850px; overflow: visible; }
.annual-chart svg line { stroke: var(--line); }
.annual-chart svg .annual-zero-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; }
.annual-chart svg .annual-grid-line { stroke: var(--line); stroke-width: 1; }
.annual-chart svg .annual-axis-label, .annual-chart svg .annual-axis-title, .annual-chart svg .annual-zero-label { fill: var(--muted); font-size: 10px; }
.annual-chart svg .annual-axis-title { font-size: 11px; }
.annual-chart svg .annual-zero-label { fill: var(--text); font-weight: 760; }
.annual-chart svg .annual-cumulative-line { pointer-events: none; }
.annual-chart svg .annual-profit-bar.negative { fill: #bd4f4f; }
.annual-chart svg text { fill: var(--muted); font-size: 10px; }
.annual-chart .chart-caption { font-size: 12px; }
.annual-chart .annual-month-hit { fill: transparent; stroke: transparent; cursor: pointer; }
.annual-chart .annual-month-hit:hover, .annual-chart .annual-month-hit:focus-visible { fill: rgba(31,79,66,.06); stroke: #73a897; stroke-width: 1; outline: none; }
.annual-chart .annual-transition-marker { cursor: pointer; }
.annual-chart .annual-value-label { fill: var(--text); font-size: 8px; font-weight: 700; pointer-events: none; }
.annual-chart .annual-profit-label.negative { fill: var(--danger); }
.annual-label-toggle { display: inline-flex; grid-template-columns: none; align-items: center; gap: 7px; margin: 2px 0 8px; }
.annual-label-toggle input { width: 18px; min-height: 18px; }
.annual-break-even { margin: 14px 0; padding: 12px 14px; border: 1px solid #cae5d6; border-radius: 12px; background: var(--success-bg); }
.annual-break-even h3 { margin: 0 0 7px; font-size: 15px; }
.annual-break-even p { margin: 3px 0; font-size: 13px; }
.annual-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; }
.annual-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; background: #376fb5; }
.annual-legend span:nth-child(2)::before { background: #45a477; }
.annual-legend span:nth-child(3)::before { background: #774bb5; }
.annual-events { padding-left: 20px; font-size: 12px; }
.annual-table { min-width: 1450px; font-size: 11px; }
.annual-table th, .annual-table td { padding: 7px 6px; white-space: nowrap; }
.annual-detail-row td { white-space: normal; }
.annual-detail-row summary { cursor: pointer; color: var(--accent); }
.annual-tax-details { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px 18px; padding: 8px; font-size: 12px; }
.annual-preset-state { color: var(--muted); font-size: 12px; }
.growth-config { margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.growth-config h3 { margin: 0 0 10px; }
.growth-values { grid-template-columns: repeat(6,minmax(70px,1fr)); margin: 12px 0; }
.growth-values input { width: 100%; min-width: 50px; padding: 7px; }
.growth-kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; margin: 14px 0; }
.growth-kpis .metric { padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.growth-kpis .value { display: block; margin-top: 4px; font-size: 16px; }
.growth-kpis .sub { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.growth-chart, .growth-events { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.growth-chart > label { display: inline-flex; align-items: center; gap: 7px; margin: 4px 12px 8px 0; }
.growth-chart select { min-width: 145px; }
.growth-chart svg { display: block; width: 100%; min-width: 760px; height: auto; }
.growth-chart svg circle { fill: #1f4f42; stroke: #fff; stroke-width: 2; cursor: pointer; }
.growth-chart svg circle:focus { stroke: #bc7735; stroke-width: 4; outline: none; }
.growth-point-tooltip { padding: 10px 12px; margin: 8px 0; border: 1px solid var(--strong-line); border-radius: 10px; background: var(--surface); font-size: 12px; line-height: 1.55; }
.growth-events p { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.growth-events p:last-child { border-bottom: 0; }
.growth-roles { display: grid; gap: 9px; margin-top: 10px; }
.growth-role { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.growth-role > strong, .growth-role > .hint { grid-column: 1 / -1; }
.growth-role .hint { margin: 0; }
.growth-role label { display: grid; gap: 4px; font-size: 12px; }
.growth-role input, .growth-role select { width: 100%; min-width: 0; }
.growth-role label:has(input[type="checkbox"]) { display: flex; align-items: center; }
.growth-table { min-width: 1450px; }

.app-footer { padding-top: 20px; padding-bottom: 42px; color: var(--muted); font-size: 12px; }
.hidden { display: none !important; }
.mobile-recalc { display: none; }

@media (max-width: 1280px) {
  .summary-grid { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .results-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .warnings-card, .result-card:first-child { grid-column: 1 / -1; }
  #employmentComparisonCard { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .app-header, .app-shell, .app-footer { padding-left: 12px; padding-right: 12px; }
  .app-header { padding-top: 6px; padding-bottom: 6px; display: flex; gap: 8px; align-items: center; }
  .app-header .subtitle { display: none; }
  .app-header .privacy-badge { margin-left: auto; }
  .scenario-bar { position: static; display: grid; }
  .scenario-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .scenario-select-wrap { min-width: 0; }
  .scenario-bar .current-period-control label { display: grid; gap: 4px; }
  .scenario-bar .current-period-control select { min-width: 105px; }
  .toolbar { justify-content: flex-start; }
  .calculation-status { width: 100%; justify-content: center; }
  #recalculateTopBtn { flex: 1 1 160px; }
  .recalc-notice { align-items: stretch; flex-direction: column; }
  .recalc-notice .button { width: 100%; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .annual-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .growth-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .annual-month-inputs { grid-template-columns: repeat(4,minmax(56px,1fr)); }
  .growth-values { grid-template-columns: repeat(3,minmax(56px,1fr)); }
  .growth-role { grid-template-columns: 1fr 1fr; }
  .growth-role > strong, .growth-role > .hint { grid-column: 1 / -1; }
  .growth-chart { overflow-x: auto; }
  .annual-chart { overflow-x: auto; }
  .annual-tax-details { grid-template-columns: 1fr; }
  .results-column { grid-template-columns: 1fr; }
  .result-card:first-child, .warnings-card { grid-column: auto; }
  .grid-2, .kpi-list { grid-template-columns: 1fr; }
  .comparison-kpis { grid-template-columns: 1fr; }
  .mode-tabs, .result-tabs { width: 100%; overflow-x: auto; }
  .mode-tabs button, .result-tabs button { flex: 1; padding: 9px 8px; white-space: nowrap; font-size: 12px; }
  .product-row { grid-template-columns: 1fr 1fr; }
  .product-row .product-advanced { grid-column: 1; }
  .product-row .editor-actions { grid-column: 2; justify-content: flex-end; }
  .fund-row { grid-template-columns: 1fr 1fr; padding: 10px 0; }
  .fund-row > strong, .fund-row > span { grid-column: span 2; }
  .fund-row > select, .fund-row > input { min-width: 0; }
  .waterfall { grid-template-columns: 1fr 1fr; }
  .whatif-row { flex-direction: column; }
  .toolbar-more { margin-left: auto; }
  .toolbar-menu { right: 0; }
  .editor-table, .editor-table tbody, .editor-table tr, .editor-table td { display: block; min-width: 0; width: 100%; }
  .editor-table thead { display: none; }
  .editor-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 9px; border-bottom: 1px solid var(--line); }
  .editor-table td { border: 0; padding: 2px; }
  .editor-table td:first-child, .editor-table td:last-child { grid-column: 1 / -1; }
  .editor-table input, .editor-table select { min-width: 0; }
  .current-period-control { justify-content: stretch; margin: 0; }
  .current-period-control label { justify-content: space-between; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .current-period-control select { min-width: 130px; }
  .current-role-card { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; padding: 10px; }
  .current-role-card .role-name, .current-role-card .role-productivity { grid-column: 1 / -1; }
  .current-role-card .role-actions { grid-column: 2; justify-content: flex-end; }
  .productivity-fields { grid-template-columns: 1fr 1fr; }
  body.guided-current .table-scroll { overflow-x: visible; border: 0; }
  body.guided-current #expensesTable, body.guided-current #expensesTable tbody, body.guided-current #expensesTable tr, body.guided-current #expensesTable td { display: block; width: 100%; }
  body.guided-current #expensesTable thead { display: none; }
  body.guided-current #expensesTable tr { display: grid; grid-template-columns: minmax(0,1fr) minmax(110px,.9fr) auto; gap: 7px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  body.guided-current #expensesTable td { padding: 0; border: 0; }
  body.guided-current #expensesTable td:first-child::before { content: "Тип"; }
  body.guided-current #expensesTable td:nth-child(2)::before { content: "Название"; }
  body.guided-current #expensesTable td:nth-child(4)::before { content: "Сумма / ставка"; }
  body.guided-current #expensesTable td:last-child::before { content: "Действия"; }
  body.guided-current #expensesTable td::before { display: block; margin: 2px 0 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
  body.guided-current #expensesTable td:last-child { align-self: end; }
  #rolesTable td:nth-child(1)::before { content: "Роль"; }
  #rolesTable td:nth-child(3)::before { content: "Выплата одному человеку"; }
  #rolesTable td:nth-child(5)::before { content: "Оформление"; }
  #rolesTable td:nth-child(7)::before { content: "Количество сотрудников"; }
  body.guided-current #rolesTable td:nth-child(7)::before { content: "Количество сотрудников сейчас"; }
  #expensesTable td:nth-child(1)::before { content: "Тип расхода"; }
  #expensesTable td:nth-child(2)::before { content: "Название"; }
  #expensesTable td:nth-child(4)::before { content: "Сумма / ставка"; }
  .editor-table td::before { display: block; margin: 2px 0 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
  .mobile-recalc:not(.hidden) { position: fixed; inset: auto 0 0; z-index: 40; display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); box-shadow: 0 -4px 18px rgba(23,23,21,.1); }
  .mobile-recalc span { font-size: 12px; font-weight: 700; }
  .mobile-recalc .button { min-width: 140px; }
  body { padding-bottom: 62px; }
  .span-2 { grid-column: auto; }
  .metric { min-height: 84px; }
  .metric .value { font-size: 17px; }
}
