:root {
  --charcoal: #424242;
  --red: #D80032;
  --bg: #f7f7f8;
  --card-bg: #ffffff;
  --border: #e2e2e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--charcoal);
}

.header {
  background: #ffffff;
  border-bottom: 3px solid var(--red);
  padding: 16px 0;
}
.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}
.brand {
  color: var(--charcoal);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}
.brand-logo {
  max-height: 40px;
  max-width: 220px;
  display: block;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.badge-banner {
  background: #fff0f4;
  border: 1px solid var(--red);
  color: var(--charcoal);
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 24px;
}

.error-box {
  background: #fff3f3;
  border: 1px solid var(--red);
  padding: 16px;
  border-radius: 8px;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.plan-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  padding-bottom: 34px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.plan-card.zero-cost {
  border: 2px solid var(--red);
}

.plan-metal {
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 0.05em;
}

.carrier-logo {
  max-height: 28px;
  max-width: 140px;
  object-fit: contain;
}

.plan-card h2 {
  font-size: 1.05rem;
  margin: 0;
}

.plan-issuer {
  color: #777;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quality-stars {
  color: var(--red);
  font-size: 0.85rem;
  letter-spacing: -1px;
}

.plan-premium {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--charcoal);
}
.per-month {
  font-size: 0.9rem;
  font-weight: 400;
  color: #777;
}

.premium-detail {
  font-size: 0.8rem;
  color: #999;
  margin-top: -4px;
}
.premium-full {
  text-decoration: line-through;
}

.plan-costs {
  width: 100%;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
}
.cost-row {
  display: flex;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid #f0f0f0;
}
.plan-costs .cost-row:first-child {
  border-top: none;
}
.cost-label {
  color: #666;
  flex: 0 1 auto;
  white-space: normal;
}
.cost-spacer {
  flex: 1 1 auto;
  min-width: 18px;
}
.cost-value {
  font-weight: 600;
  text-align: right;
  flex: 0 1 auto;
  max-width: 60%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.plan-links {
  font-size: 0.8rem;
}
.plan-links a {
  color: var(--red);
  text-decoration: none;
}
.plan-links a:hover {
  text-decoration: underline;
}
.link-sep {
  color: #ccc;
  margin: 0 6px;
}

.zero-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  width: fit-content;
}

.enroll-btn {
  margin-top: auto;
  display: block;
  text-align: center;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 12px;
  border-radius: 8px;
}
.enroll-btn:hover {
  opacity: 0.9;
}

.footer {
  text-align: center;
  padding: 24px;
  color: #999;
  font-size: 0.85rem;
}

.debug-panel {
  margin-top: 32px;
  padding: 16px 20px;
  background: #fff8e1;
  border: 1px dashed #d9a441;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #5c4a1a;
  font-family: monospace;
  line-height: 1.6;
}

/* Coverage search (drugs / providers) */
.coverage-search {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}
.coverage-search h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.coverage-search-sub {
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: #777;
}
.coverage-search-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.search-box {
  position: relative;
}
.search-box label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--charcoal);
}
.search-box input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}
.search-box input[type="text"]:focus {
  outline: none;
  border-color: var(--red);
}
.search-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.search-dropdown-item {
  padding: 8px 12px;
  font-size: 0.9rem;
  cursor: pointer;
}
.search-dropdown-item:hover {
  background: #fff0f4;
}
.search-dropdown-empty {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: #999;
}
.search-selected {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.selected-chip {
  display: inline-block;
  background: #fff0f4;
  border: 1px solid var(--red);
  color: var(--charcoal);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
}
.selected-chip a {
  color: var(--red);
  text-decoration: none;
  font-weight: 700;
}

.coverage-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.coverage-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-covered {
  background: #e7f7ec;
  color: #1a7a3a;
}
.badge-not-covered {
  background: #fdeaea;
  color: #b3261e;
}
.badge-unknown {
  background: #f0f0f0;
  color: #777;
}

/* Household & income summary panel */
.summary-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}
.summary-panel h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.summary-label {
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.summary-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--charcoal);
}
.summary-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}
.summary-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-form-row label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--charcoal);
}
.summary-form-row input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  width: 160px;
}
.summary-form-row input:focus {
  outline: none;
  border-color: var(--red);
}
.recalculate-btn {
  background: var(--red);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
}
.recalculate-btn:hover {
  opacity: 0.9;
}
.summary-form-note {
  margin: 10px 0 0;
  font-size: 0.75rem;
  color: #999;
}

/* Full household edit form */
.edit-form {
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}
.edit-quick-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}
.edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.edit-field-wide {
  flex: 1 1 100%;
  max-width: 320px;
}
.edit-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--charcoal);
}
.edit-field input,
.edit-field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  width: 170px;
}
.edit-field input:focus,
.edit-field select:focus {
  outline: none;
  border-color: var(--red);
}
.edit-details {
  margin-top: 16px;
}
.edit-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--red);
  font-size: 0.9rem;
  padding: 6px 0;
}
.edit-section {
  padding: 14px 0;
  border-top: 1px solid #f0f0f0;
}
.edit-section h4 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--charcoal);
}
.edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 10px;
}
.edit-details .recalculate-btn {
  margin-top: 12px;
}

.agent-tool-sub {
  color: #777;
  margin-bottom: 24px;
}

/* Metal tier tabs */
.tier-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.tier-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.show-all-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--charcoal);
  cursor: pointer;
  white-space: nowrap;
}
.show-all-toggle input {
  cursor: pointer;
}
.tier-tab {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--charcoal);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.tier-tab:hover {
  border-color: var(--red);
}
.tier-tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.tier-count {
  opacity: 0.7;
  font-weight: 400;
}

/* Compare checkbox in the corner of each plan card */
.compare-checkbox {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.7rem;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.compare-checkbox input {
  cursor: pointer;
}

/* Floating compare bar */
.compare-bar {
  position: sticky;
  bottom: 16px;
  margin: 16px auto 0;
  max-width: 600px;
  background: var(--charcoal);
  color: #fff;
  border-radius: 10px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  z-index: 20;
}
.compare-bar .recalculate-btn {
  padding: 8px 16px;
  font-size: 0.85rem;
}
.compare-clear-btn {
  background: none;
  border: 1px solid #fff;
  color: #fff;
  font-size: 0.8rem;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
}

/* Compare modal */
.compare-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.compare-modal-inner {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  max-width: 95vw;
  max-height: 85vh;
  overflow: auto;
  position: relative;
}
.compare-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 0.9rem;
  color: var(--charcoal);
  cursor: pointer;
  font-weight: 700;
}
.compare-boxes {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.compare-box {
  flex: 0 0 260px;
  width: 260px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.compare-box .plan-costs {
  font-size: 0.78rem;
}
.compare-details-link {
  margin-top: auto;
}

.edit-field-narrow input {
  width: 100px;
}
