:root {
  --navy: #1a365d;
  --blue: #2b6cb0;
  --blue-light: #ebf4ff;
  --accent: #2b6cb0;
  --accent-hover: #1a5a9e;
  --orange: #d69e2e;
  --orange-bg: #fefcbf;
  --gray-50: #f7fafc;
  --gray-100: #edf2f7;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e0;
  --gray-400: #a0aec0;
  --gray-500: #718096;
  --gray-600: #4a5568;
  --gray-700: #2d3748;
  --gray-800: #1a202c;
  --error: #b94a48;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Scenario colors — neutral, equally weighted, no bias */
  --color-15: #7a7a7a;  /* neutral gray */
  --color-11: #5b8db8;  /* steel blue */
  --color-9: #7b5ea7;   /* purple */
  --color-6: #c17f3e;   /* amber */
  --color-3: #5a8a8a;   /* teal slate */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--gray-800); background: var(--gray-50); line-height: 1.5; }

/* Header */
.header { background: var(--navy); color: white; padding: 2rem 1.5rem; text-align: center; }
.header h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; }
.header .subtitle { color: #bee3f8; font-size: 1rem; margin-bottom: 1rem; }
.header .base-rate { display: inline-block; background: rgba(255,255,255,0.15); border-radius: 8px; padding: 0.5rem 1.25rem; font-size: 1.1rem; }
.header .base-rate strong { color: white; font-size: 1.3rem; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem 10rem; }

/* Loading state */
.loading { text-align: center; padding: 3rem; color: var(--gray-500); font-size: 1.1rem; }
.load-error { text-align: center; padding: 2rem; color: var(--error); background: #fdf2f2; border: 1px solid #e2b8b8; border-radius: 8px; margin: 2rem; }

/* Section headings */
.section-heading { font-size: 1.1rem; font-weight: 600; color: var(--navy); margin: 1.75rem 0 0.5rem; }
.section-note { font-size: 0.72rem; color: var(--gray-500); margin: -0.25rem 0 0.75rem; }

/* Presets */
.presets { padding: 1.25rem 0; position: sticky; top: 0; background: var(--gray-50); z-index: 20; border-bottom: 1px solid var(--gray-200); }
.preset-row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.preset-btn {
  border: 2px solid var(--gray-300); background: white; border-radius: 8px;
  padding: 0.5rem 1rem; cursor: pointer; text-align: center; min-width: 130px;
  transition: all 0.15s; font-family: var(--font); font-size: 0.9rem;
}
.preset-btn:hover { border-color: var(--blue); background: var(--blue-light); }
.preset-btn.active { border-color: var(--blue); background: var(--blue); color: white; }
.preset-btn .plan-name { font-weight: 700; font-size: 1rem; }
.preset-btn .plan-rate { font-size: 0.8rem; opacity: 0.85; }
.preset-btn.active .plan-rate { opacity: 1; }

/* Scenario-colored preset buttons when active */
.preset-btn[data-preset="15"].active { border-color: var(--color-15); background: var(--color-15); }
.preset-btn[data-preset="11"].active { border-color: var(--color-11); background: var(--color-11); }
.preset-btn[data-preset="9"].active  { border-color: var(--color-9);  background: var(--color-9); }
.preset-btn[data-preset="6"].active  { border-color: var(--color-6);  background: var(--color-6); }
.preset-btn[data-preset="3"].active  { border-color: var(--color-3);  background: var(--color-3); }

.preset-btn.custom-badge {
  border-color: var(--orange); background: var(--orange-bg); color: var(--gray-700);
}
.preset-btn.custom-badge .plan-name { color: var(--gray-700); }

/* Table wrapper */
.table-wrap { overflow-x: auto; margin: 1rem 0; border-radius: 8px; border: 1px solid var(--gray-200); background: white; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { position: sticky; top: 0; z-index: 10; }
thead th {
  background: var(--gray-100); border-bottom: 2px solid var(--gray-200);
  padding: 0.6rem 0.75rem; text-align: left; font-weight: 600; white-space: nowrap;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-600);
}
thead th.center { text-align: center; }
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background 0.1s; }
tbody tr:nth-child(even) { background: var(--gray-50); }
tbody tr:hover { background: var(--blue-light); }
tbody td { padding: 0.4rem 0.75rem; vertical-align: middle; }
tbody td.desc { min-width: 200px; font-size: 0.85rem; line-height: 1.3; }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 0.85rem; }
tbody td.pct-cell { font-weight: 600; }
tbody td.center { text-align: center; }
td.inactive { color: var(--gray-400); }

/* Slider cell */
.slider-cell { width: 150px; min-width: 150px; padding: 0.3rem 0.5rem !important; }
.slider-wrap { position: relative; width: 100%; }
.slider-wrap input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  background: var(--gray-200); border-radius: 3px; outline: none; margin: 0;
}

/* Slider thumb — colored by scenario level */
.slider-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
  border-radius: 50%; cursor: pointer; border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3); background: var(--gray-400);
}
.slider-wrap input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  cursor: pointer; border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3); background: var(--gray-400);
}

/* Level-specific thumb colors (WebKit) */
.slider-wrap[data-level="0"] input[type=range]::-webkit-slider-thumb { background: var(--color-15); }
.slider-wrap[data-level="1"] input[type=range]::-webkit-slider-thumb { background: var(--color-11); }
.slider-wrap[data-level="2"] input[type=range]::-webkit-slider-thumb { background: var(--color-9); }
.slider-wrap[data-level="3"] input[type=range]::-webkit-slider-thumb { background: var(--color-6); }
.slider-wrap[data-level="4"] input[type=range]::-webkit-slider-thumb { background: var(--color-3); }

/* Level-specific thumb colors (Firefox) */
.slider-wrap[data-level="0"] input[type=range]::-moz-range-thumb { background: var(--color-15); }
.slider-wrap[data-level="1"] input[type=range]::-moz-range-thumb { background: var(--color-11); }
.slider-wrap[data-level="2"] input[type=range]::-moz-range-thumb { background: var(--color-9); }
.slider-wrap[data-level="3"] input[type=range]::-moz-range-thumb { background: var(--color-6); }
.slider-wrap[data-level="4"] input[type=range]::-moz-range-thumb { background: var(--color-3); }

/* Tick labels under slider */
.tick-labels {
  display: flex; justify-content: space-between; padding: 1px 2px 0;
  font-size: 0.65rem; line-height: 1; user-select: none;
}
.tick-labels span { width: 18px; text-align: center; color: var(--gray-500); }
.tick-labels span.unavail { color: var(--gray-300); }

/* Colored tick labels */
.tick-labels span[data-sc="15"] { color: var(--color-15); font-weight: 600; }
.tick-labels span[data-sc="11"] { color: var(--color-11); font-weight: 600; }
.tick-labels span[data-sc="9"]  { color: var(--color-9);  font-weight: 600; }
.tick-labels span[data-sc="6"]  { color: var(--color-6);  font-weight: 600; }
.tick-labels span[data-sc="3"]  { color: var(--color-3);  font-weight: 600; }
.tick-labels span.unavail { color: var(--gray-300) !important; font-weight: 400 !important; }

/* Active tick (current slider position) gets underline emphasis */
.tick-labels span.active-tick { text-decoration: underline; font-weight: 700; }

/* Alignment indicator */
.align-ind { width: 28px; text-align: center; font-size: 0.9rem; }
.align-match { color: var(--navy); }

/* Summary footer */
.summary {
  background: white; border: 2px solid var(--blue); border-radius: 10px;
  padding: 1.25rem 1.5rem; margin: 1.5rem 0; position: sticky; bottom: 0; z-index: 15;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}
.summary-grid { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin-bottom: 0.75rem; }
.summary-item { text-align: center; }
.summary-item .label { font-size: 0.75rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
.summary-item .value { font-size: 1.5rem; font-weight: 700; color: var(--navy); }
.summary-item .value.rate { color: var(--blue); }
.summary-compare { font-size: 0.85rem; color: var(--gray-600); margin-top: 0.25rem; }

/* Email button */
.email-section { text-align: center; margin: 1.5rem 0; }
.email-btn {
  display: inline-block; background: var(--accent); color: white; font-size: 1.1rem;
  font-weight: 600; padding: 0.9rem 2.5rem; border-radius: 8px; text-decoration: none;
  transition: background 0.15s; font-family: var(--font); border: none; cursor: pointer;
}
.email-btn:hover { background: var(--accent-hover); }
.open-email-btn { background: var(--navy); }
.open-email-btn:hover { background: var(--accent); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: flex-start;
  padding: 2rem 1rem; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 10px; max-width: 800px; width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2); max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 1.1rem; color: var(--navy); }
.modal-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: var(--gray-500); padding: 0 0.25rem; line-height: 1;
}
.modal-close:hover { color: var(--gray-800); }
.modal-info {
  padding: 0.75rem 1.5rem; background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem; color: var(--gray-600);
}
.modal-body {
  padding: 1.5rem; overflow-y: auto; flex: 1;
}
.modal-body table { font-size: 13px; }
.modal-footer {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200); background: var(--gray-50);
  border-radius: 0 0 10px 10px;
}
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: white; font-size: 1rem;
  font-weight: 600; padding: 0.6rem 1.5rem; border-radius: 8px;
  transition: background 0.15s; font-family: var(--font); border: none; cursor: pointer;
  min-width: 160px; height: 42px; white-space: nowrap;
}
.copy-btn:hover { background: var(--accent-hover); }
.copy-status { font-size: 0.9rem; color: var(--accent); font-weight: 600; min-height: 1.2em; }
.modal-hint { width: 100%; font-size: 0.75rem; color: var(--gray-500); margin-top: 0.5rem; line-height: 1.4; }

@media (max-width: 768px) {
  .email-section { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
  .preview-btn { margin-left: 0; }
  .modal { max-height: 95vh; }
  .modal-body { padding: 1rem; }
}

/* Toast notification */
.toast {
  position: fixed; bottom: -60px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: white; padding: 0.75rem 1.5rem;
  border-radius: 8px; font-size: 0.95rem; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); z-index: 2000;
  transition: bottom 0.3s ease; white-space: nowrap;
}
.toast.show { bottom: 2rem; }

/* Top disclaimer */
.disclaimer-top {
  background: var(--gray-100); border-radius: 8px; padding: 1rem 1.5rem;
  margin: 1.5rem 0 0.5rem; font-size: 0.82rem; color: var(--gray-600); line-height: 1.6;
}
.disclaimer-top p { margin-bottom: 0.4rem; }
.disclaimer-top p:last-child { margin-bottom: 0; }
.disclaimer-top a { color: var(--blue); }

/* Disclaimers */
.disclaimers {
  background: var(--gray-100); border-radius: 8px; padding: 1.25rem 1.5rem;
  margin: 1.5rem 0 2rem; font-size: 0.8rem; color: var(--gray-600); line-height: 1.6;
}
.disclaimers a { color: var(--blue); }
.disclaimers p { margin-bottom: 0.5rem; }

/* Print */
@media print {
  .presets, .email-section, .summary { position: static; }
  .header { padding: 1rem; }
  body { font-size: 10pt; }
  .slider-cell, .align-ind { display: none; }
  .table-wrap { border: 1px solid #000; }
  .disclaimers { border-top: 1px solid #999; }
}

/* Mobile */
@media (max-width: 768px) {
  .header h1 { font-size: 1.3rem; }
  .preset-btn { min-width: 70px; padding: 0.4rem 0.5rem; }
  .preset-btn .plan-name { font-size: 0.9rem; }
  .preset-btn .plan-rate { font-size: 0.7rem; }
  .summary { padding: 1rem; }
  .summary-item .value { font-size: 1.2rem; }
  table { font-size: 0.8rem; }
  tbody td.desc { min-width: 150px; }
}
