/* IIF Calculator.
 *
 * Calculator migration. Written for this service on the shell's own tokens (`--hs-*`); the monolith's page
 * styled itself with an inline <style> block and 42 style attributes, none of which this service's Content
 * Security Policy admits. The look (KPI strip, domain rows, slider, threshold badges, income bar) is the
 * source's; every width and colour is a class.
 */
:root {
  --iif-border: var(--hs-border, #dfe4ec);
  --iif-ink: var(--hs-ink, #1f2937);
  --iif-mut: var(--hs-ink-muted, #55637a);
  --iif-surface: var(--hs-surface, #fff);
  --iif-accent: var(--hs-aqua, #0d5bb8);
  --iif-good: #166534;
  --iif-good-bg: #dcfce7;
  --iif-warn: #92400e;
  --iif-warn-bg: #fef3c7;
  --iif-bad: #991b1b;
  --iif-bad-bg: #fee2e2;
  --iif-radius: 12px;
}

.iif-wrap { max-width: 1520px; margin: 0 auto; padding: 0 0 48px; }
.iif-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.iif-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--iif-accent); margin: 0 0 3px; }
.iif-title { font-size: 1.75rem; font-weight: 800; color: var(--iif-ink); margin: 0 0 6px; line-height: 1.2; }
.iif-lead { color: var(--iif-mut); font-size: 15px; margin: 0 0 20px; max-width: 760px; }
.iif-quiet { color: var(--iif-mut); font-size: 13px; margin: 6px 0 0; }
.iif-hint { color: var(--iif-mut); font-size: 12px; margin: 4px 0 0; }
.iif-opt { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--iif-mut); }

.iif-source { background: #eef5ff; color: #12365f; border: 1px solid #b9d3f5; border-left-width: 5px; border-radius: 8px; padding: 14px 18px; font-size: 14px; margin: 0 0 22px; }
.iif-source p { margin: 0 0 8px; }
.iif-source a { color: #0a4a96; font-weight: 700; }
.iif-source-title { font-size: 15px; font-weight: 800; margin: 0 0 6px; }
.iif-open { margin-top: 6px; font-size: 13px; }
.iif-open summary { cursor: pointer; font-weight: 700; padding: 6px 0; min-height: 24px; }
.iif-open ul { margin: 6px 0 8px; padding-left: 20px; }
.iif-warn { background: var(--iif-warn-bg); color: #5c3a05; border: 1px solid #e6c34a; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 0 0 16px; }
.iif-error { background: var(--iif-bad-bg); color: var(--iif-bad); border: 1px solid #f1a9a9; border-radius: 8px; padding: 10px 14px; font-size: 14px; margin: 0 0 16px; }
.iif-error:empty { display: none; }
.iif-basis { border: 0; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; }
.iif-basis legend { padding: 0; }
.iif-radio { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; cursor: pointer; min-height: 32px; }
.iif-radio input { margin-top: 3px; width: 18px; height: 18px; }
.iif-panel { margin: 0 0 14px; }
.iif-input-short { max-width: 160px; }
.iif-actions { margin: 6px 0 0; }
.iif-wrap[data-js][data-basis="adjustments"] #panel_envelope, .iif-wrap[data-js][data-basis="envelope"] #panel_adjustments { display: none; }

.iif-card { background: var(--iif-surface); border: 1px solid var(--iif-border); border-radius: var(--iif-radius); padding: 20px 22px; margin-bottom: 22px; }
.iif-card-flush { padding: 0; overflow: hidden; }
.iif-card-pad { padding: 18px 20px 12px; }
.iif-section-head { font-size: 16px; font-weight: 800; color: var(--iif-ink); margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--iif-border); }
.iif-section-head-tight { margin: 0; padding-bottom: 0; border-bottom: 0; }
.iif-label { display: block; font-size: 13px; font-weight: 700; color: var(--iif-ink); margin-bottom: 6px; }
.iif-prefill { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--iif-border); }
.iif-chipwrap { display: block; max-width: 460px; }
.iif-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px 28px; }
.iif-field { min-width: 0; }
/* On a wide page the cards and the table use the room; running text keeps a readable line length and a
   text box keeps a sensible size, so nothing is stretched to the width of the card. */
.iif-source p, .iif-source .iif-open ul, .iif-disclaimer p, .iif-quiet, .iif-hint { max-width: 980px; }
.iif-input { font: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid #c8d0dd; border-radius: 8px; background: #fff; color: var(--iif-ink); min-height: 44px; width: 100%; box-sizing: border-box; }
.iif-input-name { max-width: 340px; }
.iif-money { display: flex; align-items: stretch; border: 1px solid #c8d0dd; border-radius: 8px; overflow: hidden; max-width: 260px; background: #fff; }
.iif-money-sign { display: flex; align-items: center; padding: 0 12px; background: #f4f6fa; color: var(--iif-mut); border-right: 1px solid #c8d0dd; }
.iif-money-input { font: inherit; font-size: 14px; border: 0; padding: 10px 12px; flex: 1; min-width: 0; min-height: 44px; }
.iif-input:focus-visible, .iif-money-input:focus-visible, .ach-input:focus-visible, .ach-slider:focus-visible, .iif-btn:focus-visible { outline: 3px solid #7fb3ff; outline-offset: 2px; }

.iif-kpis { display: flex; flex-wrap: wrap; background: var(--iif-surface); border: 1px solid var(--iif-border); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.iif-kpi { flex: 1; min-width: 130px; padding: 14px 16px; text-align: center; border-right: 1px solid var(--iif-border); }
.iif-kpi:last-child { border-right: 0; }
.iif-kpi-actions { flex: 0 0 auto; min-width: auto; display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.iif-kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--iif-mut); margin-bottom: 4px; }
.iif-kpi-value { white-space: nowrap; font-size: 1.25rem; font-weight: 700; color: var(--iif-ink); font-variant-numeric: tabular-nums; }
.iif-kpi-value.good { color: var(--iif-good); }
.iif-kpi-value.warn { color: var(--iif-warn); }
.iif-btn { font: inherit; font-size: 13px; font-weight: 700; color: var(--iif-ink); background: #fff; border: 1px solid #c8d0dd; border-radius: 8px; padding: 9px 16px; min-height: 44px; cursor: pointer; white-space: nowrap; }
.iif-btn:hover { background: #f4f6fa; }
.iif-btn-primary { background: var(--iif-accent); border-color: var(--iif-accent); color: #fff; }
.iif-btn-primary:hover { background: #0a4a96; }
.iif-status { min-height: 1.2em; font-size: 13px; color: var(--iif-bad); margin: 0 0 14px; }

.iif-scroll { overflow-x: auto; }
.iif-table { width: 100%; border-collapse: collapse; margin: 0; }
.iif-table th, .iif-table td { padding: 10px 12px; vertical-align: middle; font-size: 14px; text-align: left; border-bottom: 1px solid #f0f3f6; }
.iif-table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--iif-mut); font-weight: 600; background: #f8fafc; }
.iif-table .domain-row th { background: #eff6ff; font-size: 12px; font-weight: 700; color: #1d4ed8; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid #dbeafe; padding: 8px 16px; }
.iif-table .totals-row th, .iif-table .totals-row td { background: #dbeafe; font-weight: 700; padding-left: 16px; }
.iif-c { text-align: center !important; white-space: nowrap; }
.iif-r { text-align: right !important; font-variant-numeric: tabular-nums; }
.iif-w-code { width: 96px; } .iif-w-pts { width: 64px; } .iif-w-thr { width: 110px; } .iif-w-ach { width: 210px; } .iif-w-got { width: 90px; } .iif-w-max { width: 120px; } .iif-w-earn { width: 150px; }
.iif-code { font-weight: 700; color: #1d4ed8; font-size: 13px; white-space: nowrap; }
.iif-name { font-size: 13px; line-height: 1.4; }
.iif-pts { font-weight: 600; }
.iif-thr { font-size: 12px; color: var(--iif-mut); white-space: nowrap; }

.ach-wrap { display: flex; align-items: center; gap: 8px; }
.ach-slider { flex: 1; min-width: 80px; min-height: 24px; cursor: pointer; accent-color: var(--iif-accent); }
.ach-input { width: 68px; padding: 6px 8px; font: inherit; font-size: 14px; border: 1px solid #c8d0dd; border-radius: 6px; text-align: center; min-height: 36px; box-sizing: border-box; }
.ach-pct { font-size: 13px; color: var(--iif-mut); }
.income-cell { min-width: 110px; }
.earned-val { font-weight: 600; }
.income-bar { display: block; width: 100%; height: 8px; margin: 4px 0 6px auto; border: 0; border-radius: 4px; background: #e8edf2; overflow: hidden; appearance: none; -webkit-appearance: none; }
.income-bar::-webkit-progress-bar { background: #e8edf2; }
.income-bar::-webkit-progress-value { background: var(--iif-accent); border-radius: 4px; }
.income-bar::-moz-progress-bar { background: var(--iif-accent); border-radius: 4px; }
.income-bar.full::-webkit-progress-value { background: #16a34a; }
.income-bar.full::-moz-progress-bar { background: #16a34a; }
.income-bar.warn::-webkit-progress-value { background: #f59e0b; }
.income-bar.warn::-moz-progress-bar { background: #f59e0b; }
.threshold-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.threshold-below { background: var(--iif-bad-bg); color: var(--iif-bad); }
.threshold-mid { background: var(--iif-warn-bg); color: var(--iif-warn); }
.threshold-full { background: var(--iif-good-bg); color: var(--iif-good); }

.iif-disclaimer p { margin: 0 0 8px; }
.iif-disclaimer { background: #f8fafc; border: 1px solid var(--iif-border); border-radius: 6px; padding: 12px 16px; font-size: 13px; color: var(--iif-mut); margin-bottom: 24px; }

@media (max-width: 767px) {
  .iif-kpi { min-width: 50%; }
  .iif-kpi-actions { flex: 1 1 100%; justify-content: center; }
  .ach-slider { min-width: 40px; }
  .ach-wrap { min-width: 0; }
  .ach-input { width: 60px; }
  .income-cell { min-width: 0; }
  /* The indicator table becomes one labelled card per indicator, so the achievement inputs are never
     inside a box that scrolls sideways. The headings stay for assistive technology. */
  .iif-table, .iif-table tbody { display: block; }
  .iif-table thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .iif-table tr { display: block; }
  .iif-table .domain-row th { display: block; }
  .iif-table .indicator-row { padding: 10px 14px 12px; border-bottom: 1px solid var(--iif-border); }
  .iif-table .indicator-row > th, .iif-table .indicator-row > td { display: block; border: 0; padding: 4px 0; text-align: left !important; }
  .iif-table .indicator-row > td[data-label] { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 8px; align-items: center; }
  .iif-table .indicator-row > td[data-label]::before { content: attr(data-label); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--iif-mut); }
  .iif-table .indicator-row > td.iif-r { text-align: left !important; }
  .iif-table .totals-row { padding: 10px 14px; background: #dbeafe; }
  .iif-table .totals-row > th, .iif-table .totals-row > td { display: block; background: transparent; border: 0; padding: 3px 0; text-align: left !important; }
  .iif-table .totals-row > td.iif-blank { display: none; }
  .iif-table .totals-row > td[data-label] { display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 8px; }
  .iif-table .totals-row > td[data-label]::before { content: attr(data-label); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--iif-mut); }
  .income-bar { margin-left: 0; max-width: 220px; }
}
