/* =============================================
   FEHB Premium Tracker — Style Sheet
   Aesthetic: Institutional Elegance
   Phase 4 Update: Compare Table, UX Polish
   ============================================= */

:root {
  --navy: #1B2A4A;
  --navy-light: #2A3D63;
  --navy-muted: #3D5078;
  --bg: #F4F3F0;
  --bg-warm: #ECEAE5;
  --bg-card: #FFFFFF;
  --text-primary: #1B2A4A;
  --text-secondary: #5A6478;
  --text-muted: #8891A0;
  --border: #D8D5CE;
  --border-light: #E8E6E0;
  --green: #1A7A4C;
  --green-bg: #E8F5ED;
  --red: #C23A3A;
  --red-bg: #FBEAEA;
  --amber: #B07D1B;
  --amber-bg: #FDF3DB;
  --blue-cdhp: #3B6FA0;
  --font-heading: 'DM Sans', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-sm: 0 1px 3px rgba(27, 42, 74, 0.06);
  --shadow-md: 0 4px 12px rgba(27, 42, 74, 0.08);
  --shadow-lg: 0 8px 30px rgba(27, 42, 74, 0.10);
  --transition: 0.2s ease;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ---- Skip link (accessibility) ---- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--navy);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 1rem;
}

/* ---- Focus-visible styles ---- */
:focus-visible {
  outline: 2px solid var(--navy-muted);
  outline-offset: 2px;
  border-radius: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--navy-muted);
  outline-offset: 2px;
}

/* ---- Views ---- */
.view {
  display: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.view.active {
  display: block;
  opacity: 1;
}

/* =============================================
   LANDING STATE
   ============================================= */
.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1.5rem;
  text-align: center;
}

.landing-badge {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--navy-muted);
  background: var(--bg-warm);
  border: 1px solid var(--border);
  padding: 0.35rem 1rem;
  border-radius: 20px;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
}

.landing-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.landing-subtitle {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 420px;
  line-height: 1.6;
  margin-bottom: 2.5rem;
}

/* Search box */
.search-box {
  width: 100%;
  max-width: 480px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.35rem 0.35rem 1rem;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input-wrap:focus-within {
  border-color: var(--navy-muted);
  box-shadow: var(--shadow-lg), 0 0 0 3px rgba(27, 42, 74, 0.08);
}

.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 0.75rem;
}

.search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  padding: 0.6rem 0;
  letter-spacing: 0.04em;
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0;
}

.search-input-wrap button {
  flex-shrink: 0;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  background: var(--navy);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease;
}

.search-input-wrap button:hover {
  background: var(--navy-light);
}

.search-input-wrap button:active {
  transform: scale(0.97);
}

.zip-error {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--red);
  font-weight: 500;
  min-height: 1.2em;
}

.landing-hint {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.landing-meta {
  margin-top: 3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.landing-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(27, 42, 74, 0.12);
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.7;
  text-align: center;
  max-width: 480px;
}

.landing-footer a {
  color: var(--navy-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.landing-footer p + p {
  margin-top: 0.35rem;
}

/* =============================================
   RESULTS STATE
   ============================================= */

/* Header */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

/* Change ZIP button — shows current ZIP prominently */
.change-zip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: all var(--transition);
}

.change-zip-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

.change-zip-label-zip {
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
}

.change-zip-label-sep {
  opacity: 0.45;
  margin: 0 0.1rem;
}

/* Results body */
.results-body {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem 2rem;
}

/* Info bar */
.results-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.results-info-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.zip-badge {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--navy);
  background: var(--bg-warm);
  border: 1px solid var(--border);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
}

.plan-count {
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

/* Controls bar */
.controls-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.controls-left {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Pill group row (label + pills together) */
.pill-group-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.pill-group-label {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  min-width: 62px;
}

/* Pills */
.pill-group {
  display: flex;
  gap: 0;
  background: var(--bg-warm);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 3px;
  flex-wrap: wrap;
}

.pill {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.pill:hover {
  color: var(--text-primary);
}

.pill.active {
  background: var(--bg-card);
  color: var(--navy);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Toggle group */
.toggle-group {
  display: flex;
  gap: 0;
  background: var(--bg-warm);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 3px;
}

.toggle-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.toggle-btn:hover {
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--bg-card);
  color: var(--navy);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Stats bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text-primary);
}

.stat-card-down .stat-value { color: var(--green); }
.stat-card-up .stat-value { color: var(--red); }

.stat-value.pct-up { color: var(--red); }
.stat-value.pct-down { color: var(--green); }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.filter-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  flex: 1;
  max-width: 340px;
  transition: border-color var(--transition);
}

.filter-input-wrap:focus-within {
  border-color: var(--navy-muted);
}

.filter-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.filter-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text-primary);
  background: transparent;
}

.filter-input-wrap input::placeholder {
  color: var(--text-muted);
}

.filter-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Benefits toggle button */
.benefits-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.benefits-toggle-btn:hover {
  color: var(--navy);
  border-color: var(--navy-muted);
}

.benefits-toggle-btn.active {
  color: var(--navy);
  background: var(--bg-warm);
  border-color: var(--navy-muted);
}

/* Benefits column count badge on button */
.benefits-col-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 0.05rem 0.4rem;
  min-width: 18px;
  line-height: 1.6;
  margin-left: 0.1rem;
  transition: background var(--transition), color var(--transition);
}

.benefits-toggle-btn.active .benefits-col-count {
  background: var(--navy-muted);
  color: #fff;
}

/* Onboarding row hint */
.row-hint {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--navy);
  background: rgba(27, 42, 74, 0.05);
  border: 1px solid rgba(27, 42, 74, 0.13);
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.25rem;
  animation: fadeIn 0.3s ease;
  cursor: default;
  line-height: 1.4;
}

.row-hint-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.row-hint-dismiss:hover {
  opacity: 1;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Plan count animation ---- */
@keyframes countPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.plan-count.updated {
  animation: countPop 0.25s ease;
}

/* ---- Data Table ---- */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow-x: auto;
  /* Gradient fade on right edge to hint horizontal scroll */
  position: relative;
}

/* Right-edge scroll hint (applied via JS when overflowing) */
.table-wrap.has-overflow::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 100%;
  background: linear-gradient(to left, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  z-index: 5;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

thead {
  position: sticky;
  top: 56px; /* clear the fixed results header */
  z-index: 10;
}

/* sticky thead inside overflow-x:auto breaks horizontal alignment on iOS Safari —
   disable it on mobile where vertical scroll length is short anyway */
@media (max-width: 768px) {
  thead {
    position: static;
  }
}

thead tr {
  background: var(--navy);
}

th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.92);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.85rem 1rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  position: relative;
}

th:hover {
  background: var(--navy-light);
}

th.th-compare {
  width: 44px;
  min-width: 44px;
  text-align: center;
  cursor: default;
  padding: 0.85rem 0.5rem;
}

th.th-compare:hover {
  background: var(--navy);
}

/* Chevron column header */
.th-chevron {
  width: 32px;
  min-width: 32px;
  cursor: default;
  padding: 0.85rem 0.25rem;
}

.th-chevron:hover {
  background: var(--navy);
}

th .sort-arrow {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.65rem;
  opacity: 0.35;
  transition: opacity var(--transition);
}

th.sorted .sort-arrow {
  opacity: 1;
}

/* Active sort column: subtle accent underline */
th.sorted::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.55);
  border-radius: 1px 1px 0 0;
}

th:first-child {
  border-radius: var(--radius) 0 0 0;
}
th:last-child {
  border-radius: 0 var(--radius) 0 0;
}

/* Tooltip header */
th.th-tooltip {
  position: relative;
}

.th-tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  font-size: 0.62rem;
  font-weight: 700;
  font-family: var(--font-body);
  margin-left: 0.3rem;
  cursor: help;
  vertical-align: middle;
  flex-shrink: 0;
}

.th-tooltip-popup {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--navy);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  pointer-events: none;
  line-height: 1.5;
}

.th-tooltip-popup::after {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 14px;
  border: 5px solid transparent;
  border-bottom-color: var(--navy);
}

.th-tooltip-icon:hover + .th-tooltip-popup,
.th-tooltip-icon:focus + .th-tooltip-popup {
  display: block;
}

/* Year header sub-label (Biweekly) */
.th-year-sub {
  display: block;
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.55;
  margin-top: 0.1rem;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

tbody tr {
  transition: background var(--transition), border-left-color var(--transition);
  cursor: pointer;
  border-left: 2px solid transparent;
}

tbody tr:hover {
  background: rgba(27, 42, 74, 0.032);
  border-left-color: var(--navy-muted);
}

tbody tr.detail-row {
  cursor: default;
  border-left: 2px solid transparent;
}

tbody tr.detail-row:hover {
  background: transparent;
  border-left-color: transparent;
}

tbody tr.row-expanded > td:not(.td-compare) {
  background: rgba(27, 42, 74, 0.02);
}

tbody tr.row-expanded {
  border-left-color: var(--navy);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Compare checkbox cell */
.td-compare {
  width: 44px;
  min-width: 44px;
  text-align: center;
  padding: 0.75rem 0.5rem;
  cursor: default;
  vertical-align: middle;
}

.td-compare input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--navy);
  cursor: pointer;
  vertical-align: middle;
}

/* Chevron expand cell */
.td-chevron {
  width: 32px;
  min-width: 32px;
  text-align: center;
  padding: 0.75rem 0.25rem;
  color: var(--text-muted);
  cursor: pointer;
}

.chevron-icon {
  transition: transform 0.25s ease;
}

.chevron-icon.rotated {
  transform: rotate(90deg);
}

/* Plan name cell */
.plan-name-cell {
  max-width: 280px;
}

.plan-name-text {
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  font-size: 0.85rem;
}

/* Plan meta line: option + badges + code */
.plan-meta-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}

.plan-option-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.plan-code-text {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Premium cells */
.premium-cell {
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.premium-cell.missing {
  color: var(--text-muted);
  font-weight: 400;
}

/* Change cells */
.change-cell {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.84rem;
}

.change-cell.positive {
  color: var(--red);
}

.change-cell.negative {
  color: var(--green);
}

.change-cell.neutral {
  color: var(--text-muted);
  font-weight: 400;
}

.option-cell {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  vertical-align: middle;
}

.option-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* Plan type badges */
.plan-type-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 20px;
  white-space: nowrap;
  color: #fff;
  line-height: 1.4;
}

.badge-standard {
  background: var(--navy-muted);
}

.badge-basic {
  background: var(--amber);
}

.badge-hdhp {
  background: var(--green);
}

.badge-cdhp {
  background: var(--blue-cdhp);
}

/* Plan structure badges (outline style) */
.plan-structure-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-ppo {
  color: var(--navy);
  background: transparent;
  border: 1px solid var(--navy-muted);
}

.badge-hmo {
  color: var(--green);
  background: transparent;
  border: 1px solid var(--green);
}

.badge-hmopos {
  color: var(--amber);
  background: transparent;
  border: 1px solid var(--amber);
}

.badge-epo {
  color: var(--blue-cdhp);
  background: transparent;
  border: 1px solid var(--blue-cdhp);
}

/* Benefits columns — visual separator */
th.benefits-col {
  border-left: 2px solid rgba(255,255,255,0.15);
}
th.benefits-col:first-of-type {
  border-left-width: 2px;
}
td.benefits-col {
  border-left: 2px solid var(--border-light);
}
td.benefits-col:first-of-type {
  border-left-width: 2px;
}

/* Benefit value cells */
.benefit-cell {
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.benefit-cell.muted {
  color: var(--text-muted);
  font-weight: 400;
}

.hsa-cell {
  color: var(--green);
  font-weight: 600;
}

/* Effective Annual Cost cell */
.cost-cell {
  font-family: var(--font-heading);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  color: var(--navy);
  background-origin: padding-box;
  background-repeat: no-repeat;
}

.cost-cell.muted {
  color: var(--text-muted);
  font-weight: 400;
  font-family: var(--font-body);
}

/* ---- Expandable Detail Row ---- */
.detail-row td {
  padding: 0;
  border-bottom: 1px solid var(--border-light);
}

.detail-panel {
  background: #FAFAF7;
  border-top: 2px solid var(--border);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease;
  opacity: 0;
}

.detail-panel.open {
  max-height: 600px;
  opacity: 1;
}

.detail-panel-inner {
  padding: 1.25rem 1.5rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.detail-section-title {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-light);
}

/* Mini breakdown table inside detail row */
.detail-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.detail-mini-table th {
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.5rem;
  text-align: right;
  background: transparent;
  cursor: default;
  white-space: nowrap;
}

.detail-mini-table th:hover {
  background: transparent;
}

.detail-mini-table th:first-child {
  text-align: left;
  border-radius: 0;
}

.detail-mini-table th:last-child {
  border-radius: 0;
}

.detail-mini-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.8rem;
}

.detail-mini-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
}

.detail-mini-table tr:last-child td {
  border-bottom: none;
}

.detail-mini-table td.hsa-val {
  color: var(--green);
  font-weight: 600;
}

.detail-mini-table td.dash {
  color: var(--text-muted);
  font-weight: 400;
}

/* Effective annual cost breakdown */
.detail-cost-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.3rem 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border-light);
}

.detail-cost-row:last-child {
  border-bottom: none;
}

.detail-cost-label {
  color: var(--text-secondary);
  font-weight: 400;
}

.detail-cost-value {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.detail-cost-value.total-cost {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
}

.detail-cost-value.hsa-deduct {
  color: var(--green);
}

.detail-cost-divider {
  height: 1px;
  background: var(--border);
  margin: 0.3rem 0;
}

/* Brochure link */
.detail-brochure {
  margin-top: auto;
  padding-top: 0.75rem;
}

.detail-brochure a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy-muted);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  transition: all var(--transition);
  white-space: nowrap;
}

.detail-brochure a:hover {
  background: var(--bg-warm);
  color: var(--navy);
  border-color: var(--navy-muted);
}

/* No results */
.no-results {
  padding: 3.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.no-results-icon {
  margin-bottom: 1rem;
  color: var(--border);
}

.no-results-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.no-results-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Footer */
.site-footer {
  max-width: 1440px;
  margin: 3rem auto 0;
  padding: 1.75rem 2rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.site-footer a {
  color: var(--navy-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:hover {
  color: var(--navy);
}

.site-footer-contact {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* =============================================
   COMPARE BAR (fixed bottom)
   ============================================= */
.compare-bar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(calc(100% + 2rem));
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--navy);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: 40px;
  box-shadow: 0 8px 32px rgba(27, 42, 74, 0.28), 0 2px 8px rgba(27, 42, 74, 0.15);
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  opacity: 0;
  white-space: nowrap;
}

.compare-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.compare-bar-count {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
}

.compare-bar-actions {
  display: flex;
  gap: 0.5rem;
}

.compare-bar-btn {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  border-radius: 20px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
}

.compare-bar-btn-primary {
  background: #fff;
  color: var(--navy);
}

.compare-bar-btn-primary:hover {
  background: var(--bg-warm);
}

.compare-bar-btn-ghost {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
}

.compare-bar-btn-ghost:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* =============================================
   COMPARE MODAL — TABLE LAYOUT
   ============================================= */
.compare-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 40, 0.65);
  z-index: 300;
  overflow-y: auto;
  padding: 2rem 1rem;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  align-items: flex-start;
  justify-content: center;
}

.compare-overlay.open {
  display: flex;
}

.compare-modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(15, 22, 40, 0.35);
  width: 100%;
  max-width: 1000px;
  margin: auto;
  overflow: hidden;
}

.compare-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--navy);
  color: #fff;
}

.compare-modal-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.compare-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: all var(--transition);
}

.compare-modal-close:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* Compare modal body — table container */
.compare-modal-body {
  padding: 0;
  overflow-x: auto;
  /* Gradient fade on right edge when scrollable */
  position: relative;
}

.compare-modal-body.has-overflow::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 100%;
  background: linear-gradient(to left, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
  z-index: 5;
}

/* The comparison table */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  min-width: 420px;
}

/* Plan name header row (inside <thead>) */
.compare-table thead tr.compare-thead-names th {
  background: var(--navy);
  color: #fff;
  padding: 1rem 1.25rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
  text-transform: none;
  vertical-align: top;
  border-right: 1px solid rgba(255,255,255,0.08);
  line-height: 1.35;
}

.compare-table thead tr.compare-thead-names th:last-child {
  border-right: none;
}

/* Label column (first) in header */
.compare-table thead tr.compare-thead-names th.compare-th-label {
  width: 150px;
  min-width: 130px;
  font-size: 0;
  /* invisible — just spacer */
}

/* Plan name + meta in header cell */
.compare-th-plan-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.35;
  margin-bottom: 0.35rem;
  color: #fff;
}

.compare-th-plan-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}

.compare-th-option {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: rgba(255,255,255,0.7);
}

/* Rows in the compare table body */
.compare-table tbody tr {
  border-left: none;
  cursor: default;
}

.compare-table tbody tr:hover {
  background: rgba(27, 42, 74, 0.03);
  border-left-color: transparent;
}

/* Section divider row */
.compare-table tbody tr.compare-section-row td {
  font-family: var(--font-body);
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.7rem 1.25rem 0.3rem;
  background: var(--bg);
  border-bottom: none;
}

/* Label column */
.compare-table tbody td.compare-td-label {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  width: 150px;
  min-width: 130px;
  background: var(--bg);
}

/* Value columns */
.compare-table tbody td.compare-td-value {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  vertical-align: middle;
  transition: background var(--transition);
}

.compare-table tbody td.compare-td-value.muted {
  color: var(--text-muted);
  font-weight: 400;
}

.compare-table tbody td.compare-td-value.hsa-val {
  color: var(--green);
}

/* Badges inside value cells */
.compare-td-value .plan-type-badge,
.compare-td-value .plan-structure-badge {
  display: inline-block;
}

/* Best / lowest value highlight */
.compare-td-value.best-value {
  background: var(--green-bg);
  color: var(--green);
  font-weight: 700;
}

.compare-td-value.best-value::after {
  content: '✓ Best';
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.8;
  margin-top: 0.15rem;
}

/* Effective Annual Cost footer row */
.compare-table tfoot tr td {
  background: var(--bg-warm);
  border-top: 2px solid var(--border);
  padding: 1rem 1.25rem;
  vertical-align: middle;
}

.compare-table tfoot td.compare-td-label {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--bg-warm);
  border-bottom: none;
}

.compare-table tfoot td.compare-td-value {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--navy);
  background: var(--bg-warm);
  border-bottom: none;
  border-top: none;
}

.compare-table tfoot td.compare-td-value.best-value {
  background: var(--green-bg);
  color: var(--green);
}

/* ---- Rotate-to-landscape nudge ---- */
.rotate-hint {
  display: none; /* hidden globally; shown only in portrait via media query */
}

@media (max-width: 600px) and (orientation: portrait) {
  .rotate-hint {
    display: flex;
    align-items: stretch;
    gap: 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    user-select: none;
    overflow: hidden;
  }
  .rotate-hint-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    flex: 1;
  }
  .rotate-hint-row svg {
    flex-shrink: 0;
    color: var(--navy-muted);
    opacity: 0.7;
  }
  .rotate-hint-divider {
    width: 1px;
    background: var(--border);
    flex-shrink: 0;
  }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .controls-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .results-body {
    padding: 1.25rem 1rem 2rem;
  }
  .results-header {
    padding: 0.85rem 1rem;
  }
  .detail-panel-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  /* Portrait phone: 2 columns only — Plan Name | Eff. Annual Cost */
  .th-chevron, .td-chevron,
  .th-compare, .td-compare,
  .col-year-latest,
  .col-year-old,
  .col-1yr,
  .col-2yr {
    display: none;
  }

  /* With 3 columns the table fits the viewport — no horizontal scroll needed */
  .table-wrap {
    overflow-x: hidden;
  }
  .table-wrap.has-overflow::after {
    display: none;
  }

  /* Kill the gradient bar on mobile — sub-pixel rendering looks blurry on
     high-DPI screens. */
  .cost-cell {
    background: none !important;
  }

  /* Plan name can use more width now that we have only 3 columns */
  .plan-name-cell {
    max-width: none;
  }

  .landing-title {
    font-size: 1.8rem;
  }
  .landing-subtitle {
    font-size: 0.95rem;
  }
  .search-input-wrap {
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.5rem;
  }
  .search-input-wrap input {
    width: 100%;
    text-align: center;
    padding: 0.5rem;
  }
  .search-input-wrap button {
    width: 100%;
  }
  .search-icon {
    display: none;
  }
  .pill-group {
    flex-wrap: wrap;
  }
  .pill {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
  }
  .toggle-group {
    flex-wrap: wrap;
  }
  .toggle-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
  }
  .stats-bar {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .stat-card {
    padding: 0.75rem 0.85rem;
  }
  .stat-value {
    font-size: 1.1rem;
  }
  th, td {
    padding: 0.6rem 0.65rem;
    font-size: 0.78rem;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-input-wrap {
    max-width: none;
  }
  .detail-panel-inner {
    grid-template-columns: 1fr;
  }
  /* Single-column detail panel stacks taller — raise the clip ceiling */
  .detail-panel.open {
    max-height: 1400px;
  }
  .pill-group-row {
    flex-wrap: wrap;
  }
  .pill-group-label {
    width: 100%;
  }
  .compare-bar {
    bottom: 0.75rem;
    padding: 0.7rem 1rem;
  }
  .compare-overlay {
    padding: 0.75rem 0.5rem;
  }
  /* On mobile, compare table scrolls horizontally */
  .compare-modal-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .compare-table {
    min-width: 480px;
  }
  .compare-table thead tr.compare-thead-names th.compare-th-label {
    width: 110px;
    min-width: 100px;
  }
  .compare-table tbody td.compare-td-label {
    width: 110px;
    min-width: 100px;
  }
}

@media (max-width: 400px) {
  .stats-bar {
    grid-template-columns: 1fr;
  }
}

/* Loading spinner */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 1rem;
}

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