:root {
  --bg: #f4f6f8;
  --panel-bg: #ffffff;
  --text: #1c2733;
  --muted: #5b6b7a;
  --border: #dfe4e8;
  --accent: #2b6cb0;
  --accent-dark: #1d4e89;
  --danger: #c0392b;
  --warn: #d68910;
  --good: #1e8449;
  --radius: 10px;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.app-header {
  padding: 24px clamp(16px, 4vw, 48px) 12px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
}

.ruleset-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}

.debug-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px dashed var(--muted);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.debug-toggle-label input {
  accent-color: var(--accent);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.export-pdf-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.export-pdf-btn:hover {
  background: var(--accent-dark);
}

.wizard {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(380px, 1.3fr);
  align-items: start;
  gap: 24px;
  width: 100%;
  padding: 12px clamp(16px, 4vw, 48px) 40px;
}

.wizard-left,
.wizard-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.step {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.step-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--text);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step-title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.step-chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
  margin-right: 4px;
  flex-shrink: 0;
}

.step-toggle[aria-expanded="false"] .step-chevron {
  transform: rotate(-45deg);
}

.step-toggle-fixed {
  cursor: default;
}

.step-body {
  padding: 4px 20px 22px;
}

.step-body.collapsed {
  display: none;
}

.inputs {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-row {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.input-row:first-child {
  border-top: none;
  padding-top: 0;
}

.input-row[data-column="community"] {
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.input-row > label {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 8px;
  gap: 8px;
}

.input-row .value-display {
  font-weight: 700;
  color: var(--accent-dark);
  white-space: nowrap;
}

.input-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.range-bounds {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.constraint-note {
  font-size: 0.78rem;
  color: var(--warn);
  margin-top: 6px;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.choice-row {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.choice-row:first-child {
  border-top: none;
  padding-top: 0;
}

.choice-question {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 10px;
}

.choice-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
}

.choice-option input {
  accent-color: var(--accent);
}

.choice-option:has(input:checked) {
  border-color: var(--accent);
  background: #eaf2fb;
  color: var(--accent-dark);
  font-weight: 600;
}

.multiselect-row {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.multiselect-row:first-child {
  border-top: none;
  padding-top: 0;
}

.multiselect-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.multiselect-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.86rem;
  line-height: 1.4;
  cursor: pointer;
}

.multiselect-option input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.input-row.hidden-by-condition {
  display: none;
}

.step2-grid-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 24px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}

.step2-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 24px;
  margin-bottom: 20px;
}

.step2-grid .input-row:nth-child(-n+2) {
  border-top: none;
  padding-top: 0;
}

@media (max-width: 640px) {
  .step2-grid,
  .step2-grid-header {
    grid-template-columns: 1fr;
  }
  .step2-grid .input-row:nth-child(-n+2) {
    border-top: 1px solid var(--border);
    padding-top: 16px;
  }
  .step2-grid .input-row:first-child {
    border-top: none;
    padding-top: 0;
  }
}

.pie-panels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 640px) {
  .pie-panels {
    grid-template-columns: 1fr;
  }
}

.pie-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.pie-panel h4 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.pie-chart {
  width: 150px;
  height: 150px;
  flex-shrink: 0;
}

.pie-empty {
  fill: var(--bg);
  stroke: var(--border);
  stroke-width: 1;
}

.pie-slice-label {
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.pie-legend {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  text-align: left;
}

.pie-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.pie-legend li.empty {
  color: var(--muted);
  text-align: center;
}

.pie-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pie-legend-label {
  flex: 1;
}

.pie-legend-value {
  font-weight: 700;
  color: var(--accent-dark);
  white-space: nowrap;
}

.spectrum-intro {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.85rem;
}

.spectrum-panel {
  padding: 6px 34px 4px;
}

.spectrum-track-wrap {
  position: relative;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  margin: 26px 0 30px;
}

.spectrum-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.spectrum-ticks {
  position: absolute;
  inset: 0;
}

.spectrum-tick {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--panel-bg);
  border: 2px solid var(--border);
  transform: translate(-50%, -50%);
  transition: background 0.2s, border-color 0.2s;
}

.spectrum-tick.reached {
  background: var(--accent);
  border-color: var(--accent);
}

.spectrum-needle {
  position: absolute;
  top: -18px;
  left: 0%;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 11px solid var(--accent-dark);
  transform: translateX(-50%);
  transition: left 0.25s ease;
}

.spectrum-labels {
  position: relative;
  height: 42px;
}

.spectrum-label {
  position: absolute;
  top: 0;
  width: 68px;
  text-align: center;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.25;
}

.spectrum-label.active {
  color: var(--accent-dark);
  font-weight: 800;
}

.spectrum-reason {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.traffic-light-panel {
  text-align: center;
  padding: 20px 8px;
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 20px;
}

.traffic-light {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 10px;
}

.tl-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #aab4bd;
  opacity: 0.3;
  transition: opacity 0.2s, box-shadow 0.2s, background 0.2s;
}

.tl-dot[data-color="red"].active {
  background: var(--danger);
  opacity: 1;
  box-shadow: 0 0 12px rgba(192, 57, 43, 0.6);
}

.tl-dot[data-color="amber"].active {
  background: var(--warn);
  opacity: 1;
  box-shadow: 0 0 12px rgba(214, 137, 16, 0.6);
}

.tl-dot[data-color="green"].active {
  background: var(--good);
  opacity: 1;
  box-shadow: 0 0 12px rgba(30, 132, 73, 0.6);
}

.score-label {
  font-weight: 600;
  color: var(--muted);
}

.score-debug {
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.fail-callout {
  margin-top: 14px;
  text-align: left;
  background: #fdecea;
  border-left: 3px solid var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
}

.fail-item {
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
}

.fail-item + .fail-item {
  margin-top: 6px;
}

.results-section {
  margin-bottom: 18px;
}

.results-section:last-child {
  margin-bottom: 0;
}

.results-section h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.results-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.results-section li {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--bg);
}

.results-section li.empty {
  color: var(--muted);
  background: transparent;
  padding: 0;
}

.warnings-list li.sev-high { background: #fdecea; color: var(--danger); border-left: 3px solid var(--danger); }
.warnings-list li.sev-medium { background: #fef5e7; color: var(--warn); border-left: 3px solid var(--warn); }
.warnings-list li.sev-low { background: #f0f3f5; color: var(--text); border-left: 3px solid var(--muted); }

.positives-list li { background: #eafaf1; color: var(--good); border-left: 3px solid var(--good); }

.constraints-list li { background: #eaf2fb; color: var(--accent-dark); border-left: 3px solid var(--accent); }

.score-adjustments-note {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.score-adjustments-list li.adj-positive { background: #eafaf1; color: var(--good); border-left: 3px solid var(--good); }
.score-adjustments-list li.adj-negative { background: #fdecea; color: var(--danger); border-left: 3px solid var(--danger); }

.app-footer {
  padding: 16px clamp(16px, 4vw, 48px) 32px;
  color: var(--muted);
  font-size: 0.8rem;
  max-width: 90ch;
}

/* Print-only summary sheet: built from current values in js/app.js
   (buildPrintSummary), kept invisible on screen, and revealed only inside
   @media print below so "Export Summary to PDF" (window.print) has a
   single dense page to print instead of the whole interactive wizard. */
.print-summary {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  /* Remove the interactive wizard from layout entirely (not just
     visibility:hidden) - hidden-but-still-laid-out content keeps its full
     height, which is what was producing a run of blank pages after the
     one-page summary. */
  .app-header,
  .wizard,
  .app-footer {
    display: none;
  }

  html,
  body {
    background: #fff;
  }

  .print-summary {
    display: block;
    background: #fff;
    font-size: 9pt;
    line-height: 1.22;
    color: #1c2733;
  }

  .print-header h1 {
    margin: 0 0 2px;
    font-size: 15pt;
  }

  .print-meta {
    font-size: 8pt;
    color: #5b6b7a;
    margin-bottom: 6px;
  }

  .print-status-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 5px 10px;
    border: 1px solid #dfe4e8;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 9.5pt;
  }

  .print-status-line {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .print-spectrum-line {
    font-size: 8pt;
    color: #5b6b7a;
    flex-wrap: wrap;
  }

  .print-spectrum-line strong {
    color: #1c2733;
  }

  .print-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .print-status-dot[data-color="red"] { background: #c0392b; }
  .print-status-dot[data-color="amber"] { background: #d68910; }
  .print-status-dot[data-color="green"] { background: #1e8449; }

  .print-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
    margin-bottom: 4px;
  }

  .print-col h2 {
    font-size: 8.5pt;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5b6b7a;
    margin: 8px 0 4px;
    border-bottom: 1px solid #dfe4e8;
    padding-bottom: 2px;
  }

  .print-col h2:first-child {
    margin-top: 0;
  }

  .print-col table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 4px;
  }

  .print-col table th,
  .print-col table td {
    text-align: left;
    font-weight: 400;
    font-size: 7.5pt;
    padding: 1.5px 4px 1.5px 0;
    vertical-align: top;
  }

  .print-col table th {
    width: 60%;
  }

  .print-col table td {
    font-weight: 600;
    text-align: right;
  }

  .print-qa {
    margin: 0 0 4px;
  }

  .print-qa dt {
    font-size: 7pt;
    font-weight: 600;
    margin: 3px 0 1px;
  }

  .print-qa dt:first-child {
    margin-top: 0;
  }

  .print-qa dd {
    font-size: 7pt;
    color: #5b6b7a;
    margin: 0;
  }

  .print-qa-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .print-qa-list li {
    position: relative;
    padding-left: 8px;
  }

  .print-qa-list li::before {
    content: "\2013";
    position: absolute;
    left: 0;
  }

  .print-pies {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 10px;
    margin-bottom: 4px;
  }

  .print-pie-panel {
    text-align: center;
  }

  .print-pie-panel h2 {
    font-size: 7.5pt;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #5b6b7a;
    margin: 0 0 2px;
    border-bottom: none;
    padding-bottom: 0;
  }

  .print-pie-panel svg {
    width: 18mm;
    height: 18mm;
  }

  .print-pie-panel .pie-legend {
    list-style: none;
    margin: 2px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    text-align: left;
    font-size: 6pt;
  }

  .print-pie-panel .pie-legend li {
    display: flex;
    align-items: center;
    gap: 3px;
  }

  .print-pie-panel .pie-swatch {
    width: 6px;
    height: 6px;
    border-radius: 2px;
    flex-shrink: 0;
  }

  .print-pie-panel .pie-legend-label {
    flex: 1;
  }

  .print-pie-panel .pie-legend-value {
    font-weight: 600;
    white-space: nowrap;
    color: inherit;
  }

  .print-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .print-list li {
    font-size: 7.5pt;
    padding: 2px 5px;
    margin-bottom: 3px;
    border-radius: 4px;
    background: #f0f3f5;
  }

  .print-list li.sev-high { background: #fdecea; }
  .print-list li.sev-medium { background: #fef5e7; }
  .print-list li.empty { background: transparent; color: #5b6b7a; }

  .print-footer {
    margin-top: 6px;
    font-size: 7pt;
    color: #5b6b7a;
    border-top: 1px solid #dfe4e8;
    padding-top: 4px;
  }
}
