* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: var(--lh-body);
}

button,
input,
select { font: inherit; }

button,
input,
select,
a { color: inherit; }

small[lang] { display: block; color: var(--slate); font-weight: 400; }

.site-header,
main,
.colophon {
  width: min(calc(100% - (var(--gutter) * 2)), var(--measure));
  margin-inline: auto;
}

.site-header {
  display: grid;
  grid-template-columns: auto minmax(var(--s-9), 1fr) auto;
  gap: var(--s-5);
  align-items: center;
  padding-block: var(--s-4);
  border-bottom: var(--r-hair) solid var(--rule);
}

.brand { display: flex; align-items: baseline; gap: var(--s-3); }

.wordmark {
  font-family: var(--sans);
  font-size: var(--t-sub);
  line-height: var(--lh-sub);
  font-weight: 700;
  letter-spacing: .26em;
}

.wordmark-subordinate { color: var(--muted); font-size: var(--t-label); line-height: var(--lh-note); }

.subtitle {
  margin: 0;
  max-width: var(--measure);
  color: var(--slate);
  font-size: var(--t-table);
  line-height: var(--lh-table);
}

.header-controls { display: flex; gap: var(--s-3); align-items: center; }

.segmented { display: inline-flex; border: var(--r-hair) solid var(--rule); background: var(--white); }
.segmented button { border: 0; border-right: var(--r-hair) solid var(--rule); padding: var(--s-2) var(--s-3); background: var(--white); color: var(--ink); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--navy-800); color: var(--white); }
.segmented button:disabled { color: var(--muted); }

.input-strip { padding-block: var(--s-4); border-bottom: var(--r-hair) solid var(--rule); }
.input-grid { display: grid; grid-template-columns: repeat(5, minmax(var(--s-9), 1fr)); gap: var(--s-3); }
.optional-inputs { grid-template-columns: repeat(2, minmax(var(--s-9), 1fr)); margin-top: var(--s-3); }
.field { min-width: 0; }
.dual-label { display: block; margin-bottom: var(--s-1); }
.dual-label .primary { display: block; font-size: var(--t-table); line-height: var(--lh-table); font-weight: 700; }
.dual-label .secondary { display: block; color: var(--slate); font-size: var(--t-note); line-height: var(--lh-note); }

.field input,
.field select { width: 100%; min-height: var(--s-6); border: var(--r-hair) solid var(--rule); background: var(--white); color: var(--ink); padding: var(--s-2); }

.field-note { display: block; min-height: var(--s-5); margin-top: var(--s-1); color: var(--slate); font-size: var(--t-note); line-height: var(--lh-note); }

.decision-grid { display: grid; grid-template-columns: minmax(var(--s-9), 2fr) minmax(var(--s-9), 3fr); gap: var(--s-6); padding-block: var(--s-5); align-items: start; }
.result-panel { min-width: 0; position: sticky; top: var(--s-4); padding: var(--s-5); border-top: var(--r-mark) solid var(--copper); background: var(--white); }
.eyebrow { margin: 0 0 var(--s-2); color: var(--muted); font-size: var(--t-label); line-height: var(--lh-note); font-weight: 700; text-transform: uppercase; }
.headline-value { margin: 0 0 var(--s-4); color: var(--navy-800); font-family: var(--serif); font-size: var(--t-title); line-height: var(--lh-title); font-weight: 700; white-space: nowrap; }
.sensitivity { border-top: var(--r-hair) solid var(--rule); padding-top: var(--s-3); }
.sensitivity h3 { margin: 0 0 var(--s-1); font-family: var(--sans); font-size: var(--t-label); line-height: var(--lh-note); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sensitivity-lead { margin: 0 0 var(--s-3); font-size: var(--t-note); line-height: var(--lh-note); color: var(--slate); }
.sensitivity-table { width: 100%; border-collapse: collapse; font-size: var(--t-table); line-height: var(--lh-table); }
.sensitivity-table th,
.sensitivity-table td { padding: var(--s-1) 0; text-align: left; border-bottom: var(--r-hair) solid var(--rule); vertical-align: baseline; }
.sensitivity-table thead th { font-family: var(--sans); font-size: var(--t-label); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.sensitivity-table tbody th { font-weight: 400; padding-right: var(--s-3); }
.sensitivity-table tbody tr:first-child { font-weight: 700; }
.sensitivity-effect { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result-flags p { margin: 0; padding-block: var(--s-2); border-bottom: var(--r-hair) solid var(--rule); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-4); }
.actions button { padding: var(--s-2) var(--s-3); }

.assumptions-panel { padding: var(--s-5); background: var(--white); }
.assumptions-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-3); }
.assumptions-heading h2 { margin: 0; font-size: var(--t-sub); line-height: var(--lh-sub); }
.sliders { display: grid; grid-template-columns: repeat(2, minmax(var(--s-9), 1fr)); column-gap: var(--s-5); row-gap: var(--s-3); }
.slider-row { min-width: 0; }
.slider-heading { display: flex; justify-content: space-between; gap: var(--s-3); align-items: baseline; }
.slider-heading .dual-label { margin: 0; }
.slider-value { flex: none; font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--t-table); line-height: var(--lh-table); }
.slider-track { position: relative; height: var(--s-5); display: flex; align-items: center; }
.slider-track input { width: 100%; margin: 0; accent-color: var(--copper); }
.reference-marker { position: absolute; top: var(--s-1); bottom: var(--s-1); width: var(--r-hair); background: var(--copper); pointer-events: none; }
.reference-marker::after { content: ""; position: absolute; top: 0; left: 0; width: var(--s-2); height: var(--s-2); border: var(--r-hair) solid var(--copper); background: var(--white); transform: rotate(45deg); }
.technical-name { font-family: var(--mono); font-size: var(--t-label); line-height: var(--lh-note); color: var(--slate); }

details { margin-top: var(--s-4); border-top: var(--r-hair) solid var(--rule); padding-top: var(--s-3); }
summary { cursor: pointer; font-weight: 700; font-size: var(--t-table); line-height: var(--lh-table); }
.advanced-sliders { margin-top: var(--s-3); }
.error-message { font-size: var(--t-sub); line-height: var(--lh-sub); white-space: normal; }
.visually-hidden { position: absolute; width: var(--r-hair); height: var(--r-hair); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.demonstration,
.charts,
.print-notes { margin-block: var(--s-6); }
.demonstration > h2,
.charts > h2 { font-family: var(--serif); font-size: var(--t-section); line-height: var(--lh-section); }

.calculation-table,
.calculation-table table { width: 100%; }
.calculation-table { margin-bottom: var(--s-5); background: var(--white); }
.calculation-table-heading { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-4); }
.calculation-table-heading h3 { margin: 0; font-size: var(--t-sub); line-height: var(--lh-sub); }
.method-link { color: var(--slate); font-size: var(--t-note); line-height: var(--lh-note); text-align: right; }
.calculation-table table { border-collapse: collapse; font-size: var(--t-table); line-height: var(--lh-table); font-variant-numeric: tabular-nums; }
.calculation-table thead tr { border-bottom: var(--r-hair) solid var(--rule); }
.calculation-table th,
.calculation-table td { padding: var(--s-2) var(--s-4); }
.calculation-table th { text-align: left; }
.calculation-table thead th:not(:first-child),
.calculation-table td { text-align: right; }
.calculation-table .row-note { text-align: left; }
.calculation-table .total-row { border-top: var(--r-hair) solid var(--rule); }
.table-scroll { overflow-x: auto; }
.table-note,
.table-notes,
.row-note { color: var(--slate); font-size: var(--t-note); line-height: var(--lh-note); }
.terminal-roic-comparison.is-material { padding-left: var(--s-2); border-left: var(--r-mark) solid var(--copper); color: var(--ink); }

.copy-action { display: flex; align-items: flex-start; gap: var(--s-2); }
.action-note { max-width: var(--measure); color: var(--slate); font-size: var(--t-note); line-height: var(--lh-note); }

#chart-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.charts figure { min-width: 0; margin: 0; padding: var(--s-4); background: var(--white); }
.charts figcaption { font-weight: 700; }
.charts svg { display: block; width: 100%; height: auto; overflow: visible; }
.charts rect { fill: var(--navy-800); }
.charts text { fill: var(--ink); font: var(--t-sub) var(--sans); }
.charts .explicit-value rect { fill: var(--navy-800); }
.charts .terminal-value rect { fill: var(--copper); }
.charts .value-split-chart text { fill: var(--white); }

.colophon { padding-block: var(--s-5); border-top: var(--r-hair) solid var(--rule); color: var(--slate); font-size: var(--t-note); line-height: var(--lh-note); }
.print-notes { display: none; }

@media (max-width: 900px) {
  .site-header,
  main,
  .colophon { width: min(calc(100% - (var(--gutter-m) * 2)), var(--measure)); }
  .site-header { grid-template-columns: 1fr auto; }
  .subtitle { grid-column: 1 / -1; grid-row: 2; }
  .input-grid { grid-template-columns: repeat(2, minmax(var(--s-9), 1fr)); }
  .decision-grid { grid-template-columns: 1fr; }
  .result-panel { position: static; }
}

@media (max-width: 560px) {
  .site-header { grid-template-columns: 1fr; gap: var(--s-3); }
  .subtitle { grid-column: auto; grid-row: auto; }
  .header-controls { flex-wrap: wrap; }
  .input-grid,
  .optional-inputs,
  .sliders { grid-template-columns: 1fr; }
  .headline-value { font-size: var(--t-section); line-height: var(--lh-section); white-space: normal; }
  .assumptions-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 700px) {
  #chart-list { grid-template-columns: 1fr; }
}

/* COASE design-system print margin. The document component sheet is not loaded
   because it covers documents rather than interactive artifacts. */
@page { size: A4; margin: 18mm 16mm; }

@media print {
  body { font-size: var(--p-label); line-height: var(--plh-note); }
  .site-header,
  main { width: 100%; margin: 0; }
  .header-controls,
  .assumptions-panel,
  .actions,
  .method-link,
  .result-flags,
  .colophon { display: none !important; }
  .site-header { grid-template-columns: auto 1fr; gap: var(--s-1); padding-block: 0 var(--s-1); }
  .wordmark { font-size: var(--p-sub); line-height: var(--plh-sub); }
  .wordmark-subordinate { font-size: var(--p-label); line-height: var(--plh-note); }
  .subtitle { font-size: var(--p-note); line-height: var(--plh-note); }
  .input-strip { padding-block: var(--s-1); }
  .input-grid,
  .optional-inputs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 var(--s-1); }
  .input-grid > .field {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    align-content: start;
    break-inside: avoid;
  }
  .input-grid > .field > label,
  .input-grid > .field > input,
  .input-grid > .field > select,
  .input-grid > .field > .field-note { grid-column: 1; }
  .optional-inputs { margin-top: var(--s-1); }
  .optional-field.empty-field { display: none; }
  .optional-inputs:not(:has(.optional-field:not(.empty-field))) { display: none; }
  .field input,
  .field select { min-height: 0; padding: 0; border: 0; background: var(--white); }
  .field:has(#field-sector) { grid-column: span 2; }
  #field-sector { appearance: none; }
  .field-note { min-height: 0; margin-top: 0; font-size: var(--p-note); line-height: var(--plh-note); }
  .field .dual-label { margin-bottom: 0; }
  .field .dual-label .primary { font-size: var(--p-label); line-height: var(--plh-note); }
  .field .dual-label .secondary { font-size: var(--p-note); line-height: var(--plh-note); }
  .decision-grid { display: block; padding-block: var(--s-1); }
  .result-panel { position: static; padding: 0; border-top: var(--r-mark) solid var(--copper); }
  .eyebrow { font-size: var(--p-label); line-height: var(--plh-note); }
  .headline-value { margin: 0 0 var(--s-1); font-size: var(--p-section); line-height: var(--plh-section); }
  .sensitivity { padding-top: var(--s-1); }
  .sensitivity h3 { font-size: var(--p-label); line-height: var(--plh-note); }
  .sensitivity-lead { margin: 0 0 var(--s-1); font-size: var(--p-note); line-height: var(--plh-note); }
  .sensitivity-table { font-size: var(--p-table); line-height: var(--plh-table); }
  .sensitivity-table thead th { font-size: var(--p-label); }
  .sensitivity-table th,
  .sensitivity-table td { padding: 0; }
  .sensitivity-table .secondary { display: none; }
  .demonstration { break-before: auto; margin-block: var(--s-1); }
  .demonstration > h2 { margin: var(--s-1) 0; font-size: var(--p-body); line-height: var(--plh-body); }
  #level2-tables { display: flex; flex-direction: column; }
  .calculation-table[data-table="e"] { order: 0; }
  .calculation-table[data-table="a"] { order: 1; }
  .calculation-table[data-table="b"] { order: 2; }
  .calculation-table[data-table="c"] { order: 3; }
  .calculation-table[data-table="d"] { order: 4; }
  .calculation-table { break-inside: avoid; margin-bottom: var(--s-1); }
  .calculation-table[data-table="a"] { break-inside: auto; }
  .calculation-table-heading { gap: var(--s-1); padding: 0; }
  .calculation-table-heading h3 { margin: 0; font-size: var(--p-table); line-height: var(--plh-table); }
  .calculation-table .dual-label { margin-bottom: 0; }
  .calculation-table .dual-label .primary { font-size: var(--p-label); line-height: var(--plh-note); }
  .calculation-table .dual-label .secondary { font-size: var(--p-note); line-height: var(--plh-note); }
  .calculation-table table { font-size: var(--p-table); line-height: var(--plh-table); }
  .calculation-table th,
  .calculation-table td { padding: 0 var(--s-1); }
  .calculation-table thead small { display: block; }
  .calculation-table .row-note,
  .table-note,
  .table-notes { font-size: var(--p-note); line-height: var(--plh-note); }
  .terminal-roic-comparison { margin-block: var(--s-1); }
  .table-divider { display: none !important; }
  .table-scroll { overflow: visible; }
  .charts { break-before: auto; margin-block: var(--s-1); }
  .charts > h2 { margin: var(--s-1) 0; font-size: var(--p-body); line-height: var(--plh-body); }
  #chart-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
  .charts figure { break-inside: avoid; padding: 0; }
  .charts figcaption { font-size: var(--p-label); line-height: var(--plh-note); }
  .charts text { font-size: var(--p-label); }
  .print-notes { display: block; break-before: auto; margin-block: var(--s-1); font-size: var(--p-note); line-height: var(--plh-note); }
  .print-notes h2 { margin: var(--s-1) 0; font-size: var(--p-body); line-height: var(--plh-body); }
  .print-notes table { width: 100%; border-collapse: collapse; font-size: var(--p-note); line-height: var(--plh-note); font-variant-numeric: tabular-nums; background: var(--white); }
  .print-notes th { text-align: left; }
  .print-notes th,
  .print-notes td { padding: 0 var(--s-1); vertical-align: top; }
  .print-notes thead { border-bottom: var(--r-hair) solid var(--rule); }
  .print-notes .dual-label { margin-bottom: 0; }
  .print-notes .dual-label .primary,
  .print-notes .dual-label .secondary { font-size: var(--p-note); line-height: var(--plh-note); }
  .print-parameter-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); align-items: start; }
  .print-limitations p { margin: 0; }
  .print-signature { margin-top: var(--s-1); padding-top: var(--s-1); border-top: var(--r-hair) solid var(--rule); }
}

/* Lettura della fascia dimensionale: non e' un comando, e non deve sembrarlo.
   Il premio applicato sta accanto all'etichetta perche' il numero e' il dato,
   la fascia e' solo il punto in cui ci si trova sulla curva. */
.size-reading-slot { display: flex; align-items: center; }
.size-reading {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin: 0;
  padding: .25rem .6rem;
  border: 1px solid var(--rule, #d8d3cb);
  border-radius: 2px;
  white-space: nowrap;
}
.size-reading .size-band { display: flex; flex-direction: column; line-height: 1.15; }
.size-reading .size-band small { opacity: .62; font-size: .78em; }
.size-reading .size-premium { font-variant-numeric: tabular-nums; font-weight: 600; }
