:root {
  color-scheme: dark;
  --bg: #252525; --surface: #2a2a2a; --edge: #3d3d3d; --ink: #ebebeb;
  --muted: #b4b4b4; --accent: #fef702; --title: Futura, "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 14px/1.45 Arial, system-ui, sans-serif; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button, summary, input, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; top: 0; left: 14px; z-index: 5; transform: translateY(-120%); padding: 10px; color: #111; background: var(--accent); }
.skip:focus { transform: none; }
.workspace { display: grid; grid-template-columns: clamp(165px, 14vw, 340px) minmax(0,1fr) clamp(360px, 27vw, 640px); grid-template-areas: "scenarios chart library"; gap: 12px; padding: 12px; }
.panel { min-width: 0; min-height: 0; border: 1px solid var(--edge); border-radius: 14px; background: linear-gradient(180deg, #2c2c2c, #282828); box-shadow: 0 10px 26px rgb(0 0 0 / .18); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 14px; border-bottom: 1px solid var(--edge); }
.panel-head h2 { margin: 0; color: var(--accent); font: 700 clamp(15px, 1.05vw, 20px)/1.24 var(--title); text-transform: uppercase; }
.panel-head > span { flex: none; font-size: 12px; color: var(--muted); }
.scenarios { grid-area: scenarios; display: flex; flex-direction: column; overflow: auto; }
#scenarios { display: grid; gap: 8px; padding: 12px; }
.scenario { display: flex; align-items: center; gap: 9px; min-height: 45px; padding: 9px 11px; text-align: left; border: 1px solid var(--edge); border-radius: 9px; background: var(--surface); }
.scenario[aria-pressed="true"] { border-color: color-mix(in srgb, var(--series-color) 40%, var(--edge)); background: color-mix(in srgb, var(--series-color) 7%, var(--surface)); }
.swatch { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--series-color); }
.scenario[aria-pressed="false"] .swatch { background: transparent; border: 1px solid var(--series-color); }
.scenario[aria-pressed="true"]::after { content: "✓"; margin-left: auto; color: var(--series-color); }
.scenario-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 12px 14px; }
.scenario-explainer { padding: 13px 14px 16px; border-top: 1px solid var(--edge); }
.scenario-explainer h3 { margin: 0 0 8px; color: var(--accent); font: 700 15px/1.25 var(--title); text-transform: uppercase; }
.scenario-explainer p { margin: 0; color: #d1d1d1; font-size: 14px; line-height: 1.5; }
#reset-scenarios, #export-data { border: 1px solid #505050; background: #343434; border-radius: 8px; padding: 7px 10px; font-size: 12px; }
#series-status, .chart-note, .table-note, #source-details { font-size: 12px; color: var(--muted); }
button:hover { filter: brightness(1.12); }
#source-details { margin-top: auto; padding: 13px; border-top: 1px solid var(--edge); overflow-wrap: anywhere; }
summary { cursor: pointer; color: var(--ink); }
.main-chart { grid-area: chart; display: flex; flex-direction: column; overflow: auto; }
.plot { position: relative; margin: 12px; min-height: 165px; flex: 1 1 0; border-radius: 9px; background: #232323; box-shadow: inset 0 0 0 1px #393939; }
.line-chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.axis-label, .axis-title { fill: var(--muted); font: 12px Arial, sans-serif; font-variant-numeric: tabular-nums; }
.grid-line { stroke: #3a3a3a; }
.vertical-grid { opacity: .5; }
.zero-line { stroke: #999; stroke-dasharray: 4 4; }
.chart-cursor { stroke: #bbb; stroke-dasharray: 3 3; }
.chart-overlay { cursor: crosshair; }
.inspector { padding: 0 16px 12px; }
.salary-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: var(--muted); }
#salary-value { color: var(--ink); font-size: 19px; font-weight: bold; font-variant-numeric: tabular-nums; }
#salary { width: 100%; height: 26px; margin: 1px 0 5px; accent-color: var(--accent); cursor: pointer; }
.values { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.chart-value { display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.series-label { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; }
.series-label::before { content: ""; width: 6px; height: 6px; border-radius: 100%; background: var(--series-color); }
.chart-value strong { font-size: 16px; line-height: 1.2; }
.chart-note, .table-note { margin: 0; padding: 10px 14px; border-top: 1px solid var(--edge); }
.table-view { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--edge); }
.table-toolbar p { margin: 0; color: var(--muted); }
.table-toolbar-copy { display: grid; gap: 7px; }
.table-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; font-weight: 600; }
.table-legend-up, .after-irpf-up { color: #94e8a9; }
.table-legend-down, .after-irpf-down { color: #ff9292; }
.table-toolbar button { flex: none; }
.library { grid-area: library; display: flex; flex-direction: column; overflow: auto; }
#chart-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 12px; }
.chart-option { display: flex; flex-direction: column; align-items: stretch; justify-content: space-between; gap: 8px; text-align: left; color: #ddd; background: #252525; border: 1px solid #474747; border-radius: 9px; padding: 9px; }
.chart-option[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: #302f24; }
.chart-option span { font: 600 14px/1.2 Arial, sans-serif; }
.mini-chart { display: block; width: 100%; height: clamp(36px,6dvh,83px); }
.table-preview { pointer-events: none; }
.table-preview table { height: 186px; font-size: 17px; line-height: 1.2; background: var(--surface); color: var(--ink); }
.table-preview th, .table-preview td { position: static; padding: 2px 6px; }
.explanations { border-top: 1px solid var(--edge); }
.explanations .panel-head h2 { font-size: clamp(23px,1.75vw,29px); }
.explanation-copy { padding: 14px; }
.explanation-copy h3 { margin: 0 0 6px; color: var(--ink); font: 700 16px/1.25 var(--title); }
.explanation-copy p { margin: 0; color: #d1d1d1; font-size: 14px; line-height: 1.5; }
.table-explanation dl { display: grid; gap: 9px; margin: 12px 0; }
.table-explanation dt { color: var(--ink); font-weight: 700; }
.table-explanation dd { margin: 2px 0 0; color: #d1d1d1; font-size: 14px; line-height: 1.5; }
.table-wrap { min-height: 0; overflow: auto; scrollbar-width: thin; flex: 1; }
table { width: 100%; min-width: 620px; font-size: clamp(12px,.9vw,16px); font-variant-numeric: tabular-nums; border-spacing: 0; }
#comparison-table table { min-width: 1350px; }
th, td { padding: 12px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid #393939; }
.after-irpf { font-size: inherit; font-weight: 700; }
.after-irpf-same { color: var(--ink); }
thead th { position: sticky; top: 0; z-index: 2; background: #303030; color: #c8c8c8; }
thead th span { font-size: inherit !important; }
#comparison-table .scenario-groups th { height: 42px; }
#comparison-table .scenario-group { text-align: center; border-left: 1px solid #474747; }
#comparison-table .scenario-fields th { top: 42px; color: var(--muted); font-size: 11px; }
#comparison-table .rate-heading, #comparison-table .rate-cell { border-left: 1px solid #474747; }
#comparison-table .scenario-fields th:first-child { left: auto; text-align: right; }
th:first-child { text-align: left; position: sticky; left: 0; padding-left: 10px; background: #292929; }
thead th:first-child { z-index: 3; background: #303030; }
#comparison-table .gross-heading { z-index: 4; }
tbody th { font-weight: 500; }
td:last-child, th:last-child { padding-right: 10px; }
tbody tr:nth-child(even) { background: rgb(255 255 255 / .022); }
.table-note { font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (min-width: 1051px) {
  body { height: 100dvh; display: flex; flex-direction: column; }
  .workspace { flex: 1; min-height: 0; }
}
@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0,1fr) minmax(290px,36%); grid-template-areas: "scenarios scenarios" "chart library"; align-items: start; }
  .scenarios { overflow: visible; display: block; }
  .scenarios .panel-head { padding-block: 8px; }
  #scenarios { display: flex; flex-wrap: wrap; padding: 9px 12px; gap: 6px; }
  .scenario { min-height: 36px; }
  .scenario-actions, #source-details { display: inline-flex; padding: 3px 12px 8px; border: none; }
  #source-details { display: inline-block; }
  .main-chart, .library { height: max(560px,72dvh); }
}
@media (max-width: 720px) {
  .workspace { grid-template-columns: minmax(0,1fr); grid-template-areas: "picker" "explanations" "chart" "scenarios"; padding: 10px; gap: 8px; }
  .library { display: contents; }
  .picker, .explanations { background: var(--surface); border: 1px solid var(--edge); border-radius: 12px; }
  .picker { grid-area: picker; }
  .explanations { grid-area: explanations; }
  #chart-options { gap: 5px; padding: 6px; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .chart-option { padding: 6px; gap: 4px; }
  .chart-option span { font-size: 11px; overflow-wrap: anywhere; }
  .mini-chart { height: 29px; }
  .main-chart { height: auto; }
  .plot { flex: none; height: clamp(200px,35dvh,350px); margin: 8px; }
  .panel-head { padding: 9px 11px; }
  .inspector { padding-inline: 11px; }
  .values { gap: 6px 12px; }
  .chart-value strong { font-size: 14px; }
  .table-view { min-height: 430px; max-height: 70dvh; }
  .table-toolbar { align-items: flex-start; padding: 10px; font-size: 12px; }
  .table-wrap { max-height: 60dvh; }
  table { font-size: 12px; }
}
@media print {
  body, .workspace, .main-chart, .library { display: block; height: auto; }
  .picker, .explanations, .scenarios, #export-data, #salary { display: none; }
  .plot { height: 340px; }
  .table-wrap { max-height: none; overflow: visible; }
}
