/* =============================================================================
   RBP Rate Calculator — Design System
   Healthcare/finance-oriented, data-dense, trustworthy
   Primary brand color: Navy #1F4E79 (matches Word report header)
   ============================================================================= */

/* ---------------------------------------------------------------------------
   1. DESIGN TOKENS (CSS Custom Properties)
   --------------------------------------------------------------------------- */
:root {
  /* Colors — Primary palette */
  --color-primary:        #1F4E79;   /* Navy — headings, headers, primary buttons */
  --color-primary-dark:   #163758;   /* Darker navy — hover states */
  --color-primary-light:  #2E6DA4;   /* Mid navy — accents, links */
  --color-accent:         #2E75B6;   /* Blue accent — highlights, sliders */
  --color-accent-light:   #BDD7EE;   /* Light blue — backgrounds, selected states */

  /* Colors — Neutrals */
  --color-bg:             #F5F7FA;   /* Page background */
  --color-surface:        #FFFFFF;   /* Card/panel surface */
  --color-border:         #D0D9E6;   /* Input and card borders */
  --color-border-light:   #E8EDF4;   /* Table row borders, subtle dividers */
  --color-text:           #1A2332;   /* Primary text */
  --color-text-muted:     #5A6A7E;   /* Secondary / muted text */
  --color-text-inverse:   #FFFFFF;   /* Text on dark backgrounds */

  /* Colors — Row alternation */
  --color-row-alt:        #F0F4F9;   /* Alternating table row tint */

  /* Colors — Status / Risk */
  --color-risk-high:      #C0392B;   /* Red — high risk / too low */
  --color-risk-high-bg:   #FDEDEC;
  --color-risk-moderate:  #D68910;   /* Amber — moderate risk */
  --color-risk-moderate-bg: #FEF9E7;
  --color-risk-reasonable:#1E8449;   /* Green — reasonable rate */
  --color-risk-reasonable-bg: #EAFAF1;
  --color-risk-generous:  #1F4E79;   /* Navy — generous / above-market */
  --color-risk-generous-bg: #EBF5FB;

  /* Colors — Comparison coding */
  --color-above:          #196F3D;   /* Payer above user's rate (favorable) */
  --color-above-bg:       #D5F5E3;
  --color-below:          #922B21;   /* Payer below user's rate (unfavorable) */
  --color-below-bg:       #FDEDEC;

  /* Colors — Warning banner */
  --color-warning:        #7D6608;
  --color-warning-bg:     #FEF9C3;
  --color-warning-border: #F9E79F;

  /* Colors — Percentile chart segments */
  --color-p10:            #C0392B;   /* Very low — red */
  --color-p25:            #E67E22;   /* Low — orange */
  --color-p50:            #F1C40F;   /* Median zone — yellow */
  --color-p75:            #27AE60;   /* Above median — green */
  --color-p90:            #1A5276;   /* High — dark blue */

  /* Colors — Hospital status icons */
  --color-status-ok:      #1E8449;   /* Green checkmark */
  --color-status-warn:    #D68910;   /* Amber warning */
  --color-status-fail:    #C0392B;   /* Red X */

  /* Spacing scale */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-5:   20px;
  --space-6:   24px;
  --space-8:   32px;
  --space-10:  40px;
  --space-12:  48px;

  /* Typography */
  --font-family:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                       "Helvetica Neue", Arial, sans-serif;
  --font-family-mono:  "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --font-size-xs:      11px;
  --font-size-sm:      13px;
  --font-size-base:    15px;
  --font-size-md:      16px;
  --font-size-lg:      18px;
  --font-size-xl:      22px;
  --font-size-2xl:     26px;
  --font-size-3xl:     32px;
  --font-weight-normal:  400;
  --font-weight-medium:  500;
  --font-weight-semibold:600;
  --font-weight-bold:    700;
  --line-height-tight:   1.25;
  --line-height-base:    1.5;
  --line-height-relaxed: 1.65;

  /* Layout */
  --max-width:       1100px;
  --border-radius:   6px;
  --border-radius-sm:3px;
  --border-radius-lg:10px;

  /* Shadows */
  --shadow-sm:    0 1px 3px rgba(31, 78, 121, 0.08);
  --shadow-card:  0 2px 8px rgba(31, 78, 121, 0.12);
  --shadow-raised:0 4px 16px rgba(31, 78, 121, 0.16);

  /* Transitions */
  --transition-fast:  150ms ease;
  --transition-base:  250ms ease;
}


/* ---------------------------------------------------------------------------
   2. BASE RESET & TYPOGRAPHY
   --------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-md); }
h5 { font-size: var(--font-size-base); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--color-primary-light);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

small, .text-sm  { font-size: var(--font-size-sm); }
.text-xs         { font-size: var(--font-size-xs); }
.text-muted      { color: var(--color-text-muted); }
.text-mono       { font-family: var(--font-family-mono); }

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}


/* ---------------------------------------------------------------------------
   3. LAYOUT — PAGE SHELL
   --------------------------------------------------------------------------- */
.site-header {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.site-header h1 {
  color: var(--color-text-inverse);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

.site-header .subtitle {
  font-size: var(--font-size-sm);
  opacity: 0.75;
  margin-top: 2px;
}

.site-footer {
  background: var(--color-primary);
  color: rgba(255, 255, 255, 0.65);
  font-size: var(--font-size-xs);
  text-align: center;
  padding: var(--space-4) var(--space-6);
  margin-top: var(--space-10);
}

.page-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

.layout-two-col {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: var(--space-6);
  align-items: start;
}

.layout-full {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}


/* ---------------------------------------------------------------------------
   4. CARD / PANEL COMPONENT
   --------------------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-header {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.card-header h2,
.card-header h3 {
  color: var(--color-text-inverse);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
}

.card-body {
  padding: var(--space-5);
}

.card-body + .card-body {
  border-top: 1px solid var(--color-border-light);
}

.card-footer {
  padding: var(--space-3) var(--space-5);
  background: var(--color-row-alt);
  border-top: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}


/* ---------------------------------------------------------------------------
   5. FORM COMPONENTS
   --------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  letter-spacing: 0.01em;
}

.form-hint {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Code-type indicator: shows next to the code search after selection */
.code-type-indicator {
  display: inline-block;
  margin-top: var(--space-2);
  padding: 2px 8px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: #0b3d6e;
  background: #e8f0fe;
  border: 1px solid #c0d3ea;
  border-radius: 4px;
  line-height: 1.5;
}

/* Code-type note: shown when a code has type-specific guidance */
.code-type-note {
  display: block;
  margin-top: var(--space-2);
  padding: 8px 12px;
  font-size: var(--font-size-xs);
  color: #5a4307;
  background: #fff8e6;
  border: 1px solid #f0d27a;
  border-radius: 4px;
  line-height: 1.5;
}

/* The `display: block / inline-block` rules above would otherwise win over
   the user-agent stylesheet's `[hidden] { display: none }`. These higher-
   specificity rules (class + attribute) restore the expected behavior so
   the box disappears entirely when there is no note to show. */
.code-type-indicator[hidden],
.code-type-note[hidden] {
  display: none;
}

/* Text inputs and selects */
.form-input,
.form-select {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  line-height: var(--line-height-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(46, 117, 182, 0.18);
}

.form-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.75;
}

/* Select arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235A6A7E' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Radio button group */
.radio-group {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  transition: background var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
}

.radio-option:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
}

.radio-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--transition-fast);
}

.radio-option input[type="radio"]:checked {
  border-color: var(--color-accent);
  background: var(--color-accent);
  box-shadow: inset 0 0 0 3px var(--color-surface);
}

.radio-option:has(input:checked) {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  font-weight: var(--font-weight-medium);
}

/* Range slider */
.slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.slider-value-display {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-primary);
  min-height: 20px;
}

.slider-value-display .dollar-amount {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
}

.form-range {
  width: 100%;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(to right,
    var(--color-accent) 0%,
    var(--color-accent) var(--range-fill, 50%),
    var(--color-border) var(--range-fill, 50%),
    var(--color-border) 100%
  );
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.form-range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--color-surface);
  box-shadow: 0 1px 4px rgba(31, 78, 121, 0.35);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.form-range::-webkit-slider-thumb:hover {
  background: var(--color-primary-light);
  transform: scale(1.15);
}

.form-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--color-surface);
  box-shadow: 0 1px 4px rgba(31, 78, 121, 0.35);
  cursor: pointer;
}

.form-range::-moz-range-track {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: -4px;
}


/* ---------------------------------------------------------------------------
   6. BUTTONS
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast), box-shadow var(--transition-fast),
              transform var(--transition-fast);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-accent-light);
}

.btn-lg {
  padding: var(--space-3) var(--space-8);
  font-size: var(--font-size-md);
  border-radius: var(--border-radius-lg);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
}

.btn-block {
  width: 100%;
}


/* ---------------------------------------------------------------------------
   7. AUTOCOMPLETE DROPDOWN
   --------------------------------------------------------------------------- */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  z-index: 200;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-raised);
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.autocomplete-dropdown.open { display: block; }

.autocomplete-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--color-accent-light);
}

.autocomplete-code {
  font-family: var(--font-family-mono);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  min-width: 60px;
  font-size: var(--font-size-xs);
}

.autocomplete-desc {
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ---------------------------------------------------------------------------
   8. WARNING / ALERT BANNERS
   --------------------------------------------------------------------------- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--border-radius);
  border: 1px solid transparent;
  font-size: var(--font-size-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.alert-icon {
  flex-shrink: 0;
  font-size: var(--font-size-base);
  margin-top: 1px;
}

.alert-warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning);
}

.alert-info {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  color: var(--color-primary);
}

.alert-danger {
  background: var(--color-risk-high-bg);
  border-color: var(--color-risk-high);
  color: var(--color-risk-high);
}

.alert[hidden] { display: none; }


/* ---------------------------------------------------------------------------
   9. RISK BADGES
   --------------------------------------------------------------------------- */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: 20px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.risk-high {
  background: var(--color-risk-high-bg);
  color: var(--color-risk-high);
  border: 1px solid var(--color-risk-high);
}

.risk-moderate {
  background: var(--color-risk-moderate-bg);
  color: var(--color-risk-moderate);
  border: 1px solid var(--color-risk-moderate);
}

.risk-reasonable {
  background: var(--color-risk-reasonable-bg);
  color: var(--color-risk-reasonable);
  border: 1px solid var(--color-risk-reasonable);
}

.risk-generous {
  background: var(--color-risk-generous-bg);
  color: var(--color-risk-generous);
  border: 1px solid var(--color-risk-generous);
}

/* Large risk display in results panel */
.risk-display {
  text-align: center;
  padding: var(--space-5);
}

.risk-display .risk-label {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  display: block;
}

.risk-display .risk-sublabel {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.risk-display .risk-percentile {
  font-size: var(--font-size-lg);
  margin-top: var(--space-2);
  font-weight: var(--font-weight-medium);
}


/* ---------------------------------------------------------------------------
   10. PERCENTILE DISTRIBUTION BAR CHART
   --------------------------------------------------------------------------- */
.distribution-chart {
  margin-top: 60px;
  margin-bottom: var(--space-5);
}

.distribution-bar {
  display: flex;
  height: 32px;
  border-radius: var(--border-radius);
  overflow: visible;
  position: relative;
  margin-bottom: var(--space-5);
}

/* Each colored segment: width is set inline via style="flex: <n>" */
.dist-segment {
  height: 100%;
  position: relative;
  transition: opacity var(--transition-fast);
}

.dist-segment:first-child { border-radius: var(--border-radius) 0 0 var(--border-radius); }
.dist-segment:last-child  { border-radius: 0 var(--border-radius) var(--border-radius) 0; }

.dist-segment:hover { opacity: 0.85; }

/* Tooltip on segment hover */
.dist-segment::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-text-inverse);
  font-size: var(--font-size-xs);
  padding: 3px 7px;
  border-radius: var(--border-radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.dist-segment:hover::after { opacity: 1; }

/* Segment color variants */
.dist-p10  { background: var(--color-p10); }
.dist-p25  { background: var(--color-p25); }
.dist-p50  { background: var(--color-p50); }
.dist-p75  { background: var(--color-p75); }
.dist-p90  { background: var(--color-p90); }

/* User's rate marker arrow — positioned absolutely over the bar */
.dist-marker {
  position: absolute;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.dist-marker-arrow {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--color-text);
}

.dist-marker-line {
  width: 2px;
  height: 20px;
  background: var(--color-text);
}

.dist-marker-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-align: center;
  white-space: nowrap;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 3px 6px;
  box-shadow: 0 2px 4px rgba(31, 78, 121, 0.15);
}

/* Axis labels below the bar */
.distribution-axis {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Legend for distribution segments */
.distribution-legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}


/* ---------------------------------------------------------------------------
   11. TABLES
   --------------------------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.data-table thead tr {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.data-table thead th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table thead th.align-right { text-align: right; }
.data-table thead th.align-center { text-align: center; }

.data-table tbody tr {
  border-bottom: 1px solid var(--color-border-light);
}

.data-table tbody tr:nth-child(even) {
  background: var(--color-row-alt);
}

.data-table tbody tr:hover {
  background: var(--color-accent-light);
}

.data-table tbody td {
  padding: var(--space-2) var(--space-3);
  vertical-align: middle;
}

.data-table tbody td.align-right { text-align: right; }
.data-table tbody td.align-center { text-align: center; }

.data-table tfoot td {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  background: var(--color-row-alt);
}

/* Scrollable table wrapper for overflow on mobile */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}


/* ---------------------------------------------------------------------------
   12. PAYER COMPARISON COLOR CODING
   --------------------------------------------------------------------------- */
/* "Above" = payer pays MORE than user's proposed rate (favorable — hospital more likely to accept) */
.rate-above {
  color: var(--color-above);
  background: var(--color-above-bg);
  border-radius: var(--border-radius-sm);
  padding: 1px var(--space-2);
  font-weight: var(--font-weight-medium);
}

/* "Below" = payer pays LESS than user's proposed rate (unfavorable — hospital may reject) */
.rate-below {
  color: var(--color-below);
  background: var(--color-below-bg);
  border-radius: var(--border-radius-sm);
  padding: 1px var(--space-2);
  font-weight: var(--font-weight-medium);
}

.rate-neutral {
  color: var(--color-text-muted);
}


/* ---------------------------------------------------------------------------
   13. HOSPITAL STATUS ICONS
   --------------------------------------------------------------------------- */
.status-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

/* Green checkmark — hospital likely to accept */
.status-ok {
  color: var(--color-status-ok);
}

/* Amber warning — borderline, may accept */
.status-warn {
  color: var(--color-status-warn);
}

/* Red X — hospital likely to reject */
.status-fail {
  color: var(--color-status-fail);
}

/* For use in table cells without the label */
.icon-ok::before   { content: "✓"; color: var(--color-status-ok);   font-weight: bold; }
.icon-warn::before { content: "⚠"; color: var(--color-status-warn); }
.icon-fail::before { content: "✗"; color: var(--color-status-fail); font-weight: bold; }


/* ---------------------------------------------------------------------------
   14. STAT / KPI DISPLAY
   --------------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
}

.stat-item {
  text-align: center;
  padding: var(--space-4);
  background: var(--color-row-alt);
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border-light);
  position: relative;
}

.stat-item .tooltip-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  margin-left: 0;
}

.stat-item .tooltip-icon::after {
  bottom: auto;
  top: calc(100% + 8px);
  left: auto;
  right: 0;
  transform: none;
}

.panel-summary {
  overflow: visible;
}

.panel-summary > .card-header {
  border-top-left-radius: var(--border-radius-lg);
  border-top-right-radius: var(--border-radius-lg);
}

.stat-value {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  display: block;
  line-height: var(--line-height-tight);
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-1);
  display: block;
}

/* Highlighted/featured stat */
.stat-item.featured {
  background: var(--color-primary);
  border-color: var(--color-primary-dark);
}

.stat-item.featured .stat-value,
.stat-item.featured .stat-label {
  color: var(--color-text-inverse);
}

/* Fallback notice */
/* Fallback notice — shown when the requested geography or LOB had no data
   and the result reflects a wider scope (national, all-LOB, etc.) */
.fallback-notice {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning);
  border-radius: var(--border-radius);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  margin: var(--space-3) 0;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  line-height: 1.5;
}
.fallback-notice::before {
  content: "\26A0";   /* ⚠ */
  flex: 0 0 auto;
  font-size: var(--font-size-base);
}


/* ---------------------------------------------------------------------------
   15. LOADING / SPINNER
   --------------------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

.spinner-dark {
  border-color: rgba(31, 78, 121, 0.2);
  border-top-color: var(--color-primary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}


/* ---------------------------------------------------------------------------
   16. RESULTS SECTION
   --------------------------------------------------------------------------- */
#results-container {
  display: none;   /* shown by JS after calculate */
}

#results-container.visible {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.result-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.result-code-label {
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  font-size: var(--font-size-md);
}

.proposed-rate-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--color-accent-light);
  border: 1px solid var(--color-accent);
  border-radius: var(--border-radius);
  margin-bottom: var(--space-4);
}

.proposed-rate-callout .rate-amount {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
}

.proposed-rate-callout .rate-detail {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}


/* ---------------------------------------------------------------------------
   17. REPORT PAGE SPECIFIC
   --------------------------------------------------------------------------- */
.report-header {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-8) var(--space-8) var(--space-6);
}

.report-header h1 {
  color: var(--color-text-inverse);
  font-size: var(--font-size-2xl);
}

.report-header .report-meta {
  margin-top: var(--space-3);
  font-size: var(--font-size-sm);
  opacity: 0.8;
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.report-body {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-8);
}

.report-section {
  margin-bottom: var(--space-8);
}

.report-section h2 {
  font-size: var(--font-size-lg);
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
}

.methodology-box {
  background: var(--color-row-alt);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  padding: var(--space-4) var(--space-5);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}

.methodology-box h3 {
  font-size: var(--font-size-base);
  margin-bottom: var(--space-2);
}

.report-footer {
  border-top: 2px solid var(--color-primary);
  padding: var(--space-4) 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: center;
}


/* ---------------------------------------------------------------------------
   18. UTILITY CLASSES
   --------------------------------------------------------------------------- */
.hidden  { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.p-4   { padding: var(--space-4); }
.px-4  { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-2  { padding-top: var(--space-2); padding-bottom: var(--space-2); }

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2         { gap: var(--space-2); }
.gap-4         { gap: var(--space-4); }
.flex-1        { flex: 1; }

.font-bold    { font-weight: var(--font-weight-bold); }
.font-medium  { font-weight: var(--font-weight-medium); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }

.nowrap       { white-space: nowrap; }
.mono         { font-family: var(--font-family-mono); font-size: var(--font-size-xs); }


/* ---------------------------------------------------------------------------
   19. RESPONSIVE — MOBILE (< 768px)
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .layout-two-col {
    grid-template-columns: 1fr;
  }

  .page-container {
    padding: var(--space-4) var(--space-3);
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .radio-group {
    flex-direction: column;
    gap: var(--space-2);
  }

  .site-header h1 {
    font-size: var(--font-size-lg);
  }

  .report-header {
    padding: var(--space-5) var(--space-4) var(--space-4);
  }

  .report-body {
    padding: var(--space-4) var(--space-3);
  }

  .distribution-bar {
    height: 24px;
  }

  .proposed-rate-callout {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .card-body {
    padding: var(--space-4) var(--space-3);
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .distribution-legend {
    gap: var(--space-2);
  }

  h2 { font-size: var(--font-size-lg); }
}


/* ---------------------------------------------------------------------------
   20a. CONTEXTUAL TOOLTIPS (CSS-only)
   --------------------------------------------------------------------------- */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent-light);
  color: var(--color-primary);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: background var(--transition-fast);
}

.tooltip-icon:hover {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-text-inverse);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-normal);
  padding: 8px 12px;
  border-radius: var(--border-radius);
  white-space: normal;
  width: 240px;
  line-height: var(--line-height-base);
  box-shadow: var(--shadow-raised);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 100;
  text-transform: none;
  letter-spacing: normal;
}

.tooltip-icon:hover::after {
  opacity: 1;
}


/* ---------------------------------------------------------------------------
   20b. RECOMMENDED RANGE CALLOUT
   --------------------------------------------------------------------------- */
.recommended-range-callout {
  background: linear-gradient(135deg, #EAFAF1 0%, #D5F5E3 100%);
  border: 1px solid #82E0AA;
  border-left: 4px solid var(--color-risk-reasonable);
  border-radius: var(--border-radius);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}

.recommended-range-callout.hidden { display: none; }

.recommended-range-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.recommended-range-header .range-icon {
  font-size: var(--font-size-lg);
}

.recommended-range-header .range-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-risk-reasonable);
}

.recommended-range-values {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.recommended-range-detail {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: var(--line-height-relaxed);
}


/* ---------------------------------------------------------------------------
   20c. SAVINGS CALLOUT
   --------------------------------------------------------------------------- */
.savings-callout {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  margin-top: var(--space-4);
}

.savings-callout.hidden { display: none; }

.savings-callout.savings-positive {
  background: var(--color-risk-reasonable-bg);
  border: 1px solid #82E0AA;
  color: var(--color-risk-reasonable);
}

.savings-callout.savings-negative {
  background: var(--color-risk-moderate-bg);
  border: 1px solid var(--color-risk-moderate);
  color: var(--color-risk-moderate);
}

.savings-icon {
  font-size: var(--font-size-xl);
  flex-shrink: 0;
}

.savings-amount {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
}


/* ---------------------------------------------------------------------------
   20d. SCENARIO COMPARISON
   --------------------------------------------------------------------------- */
.scenario-comparison {
  margin-bottom: var(--space-4);
}

.scenario-comparison.hidden { display: none; }

.scenario-header {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.scenario-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: var(--space-3) var(--space-4);
  text-align: center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.scenario-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-card);
}

.scenario-card.scenario-active {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
  box-shadow: var(--shadow-card);
}

.scenario-pct {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  margin-bottom: var(--space-1);
}

.scenario-rate {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.scenario-savings {
  font-size: var(--font-size-xs);
  margin-bottom: var(--space-1);
}

.scenario-acceptance {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.scenario-acceptance .acceptance-icon {
  font-size: var(--font-size-sm);
}


/* ---------------------------------------------------------------------------
   20e. QUICK START CHIPS
   --------------------------------------------------------------------------- */
.quick-start {
  margin-bottom: var(--space-4);
}

.quick-start-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

/* ─────────────────────────────────────────────
   Form Section & Step Badges
   ───────────────────────────────────────────── */
.form-section {
  padding: 2px 0;
}

.form-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.step-badge {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.step-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-section-divider {
  height: 1px;
  background: var(--color-border-light);
  margin: var(--space-4) 0;
}

/* ─────────────────────────────────────────────
   Search Input with Icon
   ───────────────────────────────────────────── */
/* ─────────────────────────────────────────────
   Selected Code Badges (Badge Row)
   ───────────────────────────────────────────── */
.selected-code-badges {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.code-type-indicator {
  display: inline-block;
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  padding: 2px 6px;
  background: #E8EDF4;
  color: var(--color-primary);
  border-radius: var(--border-radius-sm);
}

/* ─────────────────────────────────────────────
   Autocomplete Dropdown Badges
   ───────────────────────────────────────────── */
.autocomplete-system-badge {
  font-size: 9px;
  font-weight: var(--font-weight-semibold);
  padding: 1px 4px;
  border-radius: var(--border-radius-sm);
  text-transform: uppercase;
  margin-right: 2px;
}

.badge-cpt {
  background: #EAF2F8;
  color: #2471A3;
}

.badge-ms-drg {
  background: #FADBD8;
  color: #922B21;
}

.badge-hcpcs {
  background: #E8F8F5;
  color: #117864;
}

/* ─────────────────────────────────────────────
   Promoted Primary Controls Grid & Segmented Control
   ───────────────────────────────────────────── */
.primary-controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
}

@media (min-width: 600px) {
  .primary-controls-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.segmented-control {
  display: flex;
  background: var(--color-border-light);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
  width: 100%;
  box-sizing: border-box;
}

.segment-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: 6px var(--space-2);
  border-radius: 4px;
  transition: all var(--transition-fast);
  user-select: none;
  text-align: center;
  color: var(--color-text-muted);
  border: none;
}

.segment-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.segment-option:has(input:checked) {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-weight: var(--font-weight-semibold);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.segment-option:not(:has(input:checked)):hover {
  background: rgba(46, 117, 182, 0.15);
  color: var(--color-primary);
}

.setting-profile-note {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-risk-generous-bg);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ─────────────────────────────────────────────
   Collapsible Advanced Options
   ───────────────────────────────────────────── */
.advanced-section {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-bg);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.advanced-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: #E8EDF4;
  border: none;
  cursor: pointer;
  text-align: left;
  outline: none;
  font-family: var(--font-family);
}

.advanced-toggle:hover {
  background: #DEE4EC;
}

.advanced-toggle-chevron {
  font-size: 10px;
  margin-right: var(--space-2);
  transition: transform var(--transition-fast);
  color: var(--color-text-muted);
}

.advanced-toggle-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.advanced-summary {
  margin-left: auto;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.advanced-content {
  padding: var(--space-3);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

/* ─────────────────────────────────────────────
   Calculate Button Ready Pulse Nudge
   ───────────────────────────────────────────── */
@keyframes buttonPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(31, 78, 121, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(31, 78, 121, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(31, 78, 121, 0);
  }
}

.ready-pulse {
  animation: buttonPulse 2s infinite;
  border: 2px solid var(--color-accent-light) !important;
}


/* ---------------------------------------------------------------------------
   21. PRINT STYLES
   --------------------------------------------------------------------------- */
@media print {
  /* Hide interactive elements */
  .input-form,
  .btn,
  .autocomplete-dropdown,
  .site-footer,
  #calculate-btn,
  .no-print {
    display: none !important;
  }

  /* Reset backgrounds and shadows for ink economy */
  body {
    background: #fff;
    font-size: 12pt;
    color: #000;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .card-header {
    /* Keep navy header but ensure it prints */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .data-table thead tr {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .data-table tbody tr:nth-child(even) {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .distribution-bar .dist-segment {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .risk-badge,
  .risk-high,
  .risk-moderate,
  .risk-reasonable,
  .risk-generous {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 1px solid currentColor;
  }

  /* Page breaks */
  .report-section {
    break-inside: avoid;
  }

  h2, h3 {
    break-after: avoid;
  }

  table {
    break-inside: auto;
  }

  tr {
    break-inside: avoid;
  }

  /* Layout adjustments */
  .layout-two-col {
    grid-template-columns: 1fr;
  }

  .page-container,
  .report-body {
    max-width: 100%;
    padding: 0;
  }

  /* Page setup */
  @page {
    margin: 1.5cm 2cm;
    size: letter;
  }

  @page :first {
    margin-top: 1cm;
  }
}

/* =========================================================================
   FIND YOUR PROCEDURE — redesigned input section
   (rbp-app-layout-prompt3.md — replaces single search box + autocomplete)
   ========================================================================= */

/* 1. CODE TYPE chips — single-row flex with proportional widths.
   Custom flex weights so all five fit on one line at ~380px:
     Any:0.7, MS-DRG:1.3, CPT:0.7, HCPCS:1.15, Other:1                       */
.code-type-chips {
  display: flex;
  gap: 5px;
  margin-bottom: var(--space-3);
}

.code-type-chip {
  flex: 1;
  font-size: var(--font-size-sm);
  padding: 6px 0;
  text-align: center;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--color-text-muted);
  border: 0.5px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  transition: background 80ms, border-color 80ms, color 80ms;
  font-family: inherit;
}

.code-type-chip[data-chip="any"]    { flex: 0.7; }
.code-type-chip[data-chip="msdrg"]  { flex: 1.3; }
.code-type-chip[data-chip="cpt"]    { flex: 0.7; }
.code-type-chip[data-chip="hcpcs"]  { flex: 1.15; }
.code-type-chip[data-chip="other"]  { flex: 1; }

.code-type-chip:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.code-type-chip.is-selected {
  background: var(--color-accent-light);
  color: var(--color-primary);
  border-color: var(--color-accent);
  font-weight: 600;
}

/* Field label sitting above the chip row / search box / matching list */
.field-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin: 0 0 6px;
  display: block;
}

/* 2. SEARCH BOX — full-width with magnifier icon, inline (no overlay).
   Reuses .form-input look but with the icon prefix layout                    */
.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  border: 0.5px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 0 12px;
  background: var(--color-surface);
  margin-bottom: var(--space-4);
}

.search-input-wrapper:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(46, 117, 182, 0.15);
}

.search-input-wrapper svg.search-icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.search-input-wrapper input.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--font-size-base);
  color: var(--color-text);
  padding: 0;
  height: 100%;
}

/* 3. MATCHING CODES — inline panel, scrollable, single-select rows.
   Heading row with right-aligned "<N> results" count                         */
.matching-codes-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 6px;
}

.matching-codes-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  opacity: 0.7;
}

.matching-codes-panel {
  border: 0.5px solid var(--color-border-light);
  border-radius: var(--border-radius);
  background: var(--color-surface);
}

.matching-codes-list {
  max-height: 228px;
  overflow-y: auto;
  border-radius: var(--border-radius);
}

.matching-codes-list:empty::after {
  content: "Start typing or pick a code type to see matches.";
  display: block;
  padding: 14px 12px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  opacity: 0.7;
}

.matching-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--color-border-light);
  cursor: pointer;
  user-select: none;
}

.matching-code-row:last-child {
  border-bottom: none;
}

.matching-code-row:hover {
  background: var(--color-row-alt);
}

.matching-code-row.is-selected {
  background: var(--color-accent-light);
}

.matching-code-row .row-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  display: inline-block;
}

.matching-code-row.is-selected .row-icon {
  border: none;
  background: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.matching-code-row.is-selected .row-icon::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}

.matching-code-row .row-body {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  line-height: 1.35;
}

.matching-code-row .row-type-code {
  color: var(--color-text-muted);
  font-weight: 500;
  margin-right: 4px;
}

.matching-code-row.is-selected .row-type-code {
  color: var(--color-primary);
}

/* 4. BILLING CLASS + CARE SETTING — two-column adaptive grid                 */
.bc-cs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: var(--space-4);
}

.bc-cs-column h4 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--color-text);
}

.bc-cs-option {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  border: 0.5px solid var(--color-border-light);
  border-radius: var(--border-radius);
  padding: 0 10px;
  margin-bottom: 8px;
  cursor: pointer;
  user-select: none;
  background: var(--color-surface);
  transition: background 80ms, border-color 80ms;
}

.bc-cs-option:last-child {
  margin-bottom: 0;
}

.bc-cs-option input[type="radio"] {
  /* Hide the native radio; we render our own indicator dot */
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.bc-cs-option .radio-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-surface);
}

.bc-cs-option .radio-label {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.bc-cs-option:hover {
  background: var(--color-bg);
}

.bc-cs-option.is-selected {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.bc-cs-option.is-selected .radio-dot {
  border: 4px solid var(--color-primary);
  background: #fff;
}

.bc-cs-option.is-selected .radio-label {
  color: var(--color-primary);
}

/* Locked single-option rows (the column has only one valid option for this
   code type — show it pre-selected but visually de-emphasized so it reads
   as "determined by the code type", not a user choice).                     */
.bc-cs-option.is-locked {
  opacity: 0.65;
  cursor: default;
}

.bc-cs-option.is-locked:hover {
  background: var(--color-accent-light);
}


/* ---------------------------------------------------------------------------
   DEMO BANNER + LEAD CAPTURE FORM
   Inserted between site-header and main content. Visually distinct (navy
   gradient) so it reads as marketing surface, not part of the calculator.
   --------------------------------------------------------------------------- */
.demo-banner {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: var(--color-text-inverse);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  border-bottom: 4px solid var(--color-accent);
}

.demo-banner-inner {
  max-width: 760px;
  margin: 0 auto;
}

.demo-banner h2 {
  color: var(--color-text-inverse);
  font-size: var(--font-size-xxl, 24px);
  font-weight: var(--font-weight-semibold);
  line-height: 1.3;
  margin: 0 0 var(--space-3) 0;
}

.demo-banner-subhead {
  color: var(--color-text-inverse);
  opacity: 0.85;
  font-size: var(--font-size-md);
  margin: 0 0 var(--space-6) 0;
}

.demo-banner-cta {
  display: inline-block;
  padding: var(--space-3) var(--space-8);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  font-family: inherit;
  color: var(--color-primary);
  background: var(--color-text-inverse);
  border: 2px solid var(--color-text-inverse);
  border-radius: var(--border-radius-lg, 8px);
  cursor: pointer;
  box-shadow: var(--shadow-card, 0 2px 8px rgba(0,0,0,0.15));
  transition: background var(--transition-fast, 120ms), color var(--transition-fast, 120ms),
              transform var(--transition-fast, 120ms);
}

.demo-banner-cta:hover {
  background: var(--color-accent-light);
  transform: translateY(-1px);
}

.demo-banner-cta:active {
  transform: translateY(0);
}

.demo-banner-cta:focus-visible {
  outline: 3px solid var(--color-accent-light);
  outline-offset: 2px;
}

/* Lead form expansion below the CTA. Card on a translucent surface
   so it sits cleanly against the navy banner. */
.lead-form-wrapper {
  max-width: 480px;
  margin: var(--space-6) auto 0 auto;
  background: var(--color-surface);
  color: var(--color-text);
  padding: var(--space-6);
  border-radius: var(--border-radius-lg, 8px);
  box-shadow: var(--shadow-card, 0 4px 16px rgba(0,0,0,0.18));
  text-align: left;
}

.lead-form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--space-4);
}

.lead-form-row label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.lead-form-row input {
  font-family: inherit;
  font-size: var(--font-size-base);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md, 6px);
  color: var(--color-text);
  background: var(--color-surface);
}

.lead-form-row input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.lead-form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.lead-form-submit {
  padding: var(--space-2) var(--space-6);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  font-family: inherit;
  color: var(--color-text-inverse);
  background: var(--color-primary);
  border: none;
  border-radius: var(--border-radius-md, 6px);
  cursor: pointer;
  transition: background var(--transition-fast, 120ms);
}

.lead-form-submit:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.lead-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.lead-form-status {
  font-size: var(--font-size-sm);
  color: var(--color-risk-high);
}

.lead-form-result {
  padding: var(--space-4);
  border-radius: var(--border-radius-md, 6px);
  background: var(--color-risk-reasonable-bg);
  color: var(--color-text);
  font-size: var(--font-size-base);
  line-height: 1.5;
}

.lead-form-result.is-error {
  background: var(--color-risk-high-bg);
  color: var(--color-text);
}

/* Responsive: smaller headline + padding on phones */
@media (max-width: 640px) {
  .demo-banner {
    padding: var(--space-6) var(--space-4);
  }
  .demo-banner h2 {
    font-size: var(--font-size-lg, 18px);
  }
  .lead-form-wrapper {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

