:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --fg: #1f2933;
  --muted: #52606d;
  --accent: #6c5ce7;
  --accent-dark: #4336d6;
  --border: #d9e1ec;
  --card: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.panel {
  display: none;
  background: var(--card);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 10px 40px rgba(31, 41, 51, 0.08);
  margin-bottom: 2.5rem;
}

.panel.active,
.form-panel,
#profilePanel {
  display: block;
}

.hero {
  margin-bottom: 2.5rem;
}

.hero .lead {
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
}

h2 {
  margin-top: 0;
  margin-bottom: 1rem;
}

h3 {
  margin: 0 0 0.75rem;
}

.lead {
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

.muted {
  color: var(--muted);
  margin-top: -0.25rem;
  margin-bottom: 1.25rem;
}

.muted.small {
  font-size: 0.95rem;
  margin-top: -0.5rem;
}

.privacy-note {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.3);
}

button.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 26px rgba(108, 92, 231, 0.35);
}

button.secondary {
  background: white;
  color: var(--fg);
  border: 1px solid var(--border);
}

button:disabled,
button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.block {
  margin-bottom: 2rem;
}

.block.hidden {
  display: none;
}

.inner-block {
  margin-top: 1.5rem;
}

label {
  display: block;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.option-group label {
  font-weight: 500;
  background: #f1f4f8;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.option-group label:hover {
  background: #e0e7f1;
}

.flag-picker label {
  min-width: 12rem;
  justify-content: center;
}

.option-group input[type="radio"],
.option-group input[type="checkbox"] {
  accent-color: var(--accent);
}

.slider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.75rem 0 1.5rem;
}

.slider input[type="range"] {
  flex: 1;
}

.slider output {
  min-width: 4rem;
  font-weight: 600;
  text-align: right;
}

select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

select:hover {
  border-color: var(--accent);
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.cards {
  display: grid;
  gap: 1.5rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  background: white;
  display: grid;
  gap: 0.75rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #eef2ff;
  color: #312e81;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.actions {
  margin-top: 2rem;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.weights {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.weight-control {
  background: #f1f4f8;
  border-radius: 12px;
  padding: 1rem;
  display: grid;
  gap: 0.3rem;
}

.weight-control label {
  font-weight: 600;
  margin: 0;
}

.weight-control output {
  font-size: 0.95rem;
  color: var(--muted);
}

.weight-control input[type="range"] {
  width: 100%;
}

#clinicTable {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 16px;
  overflow: hidden;
}

#clinicTable th,
#clinicTable td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

#clinicTable th {
  text-align: left;
  background: #f8f9fb;
  font-size: 0.95rem;
  font-weight: 600;
}

#clinicTable td.numeric {
  text-align: right;
  font-weight: 600;
}

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

.highlight-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.checklist {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.checklist li {
  background: #f1f4f8;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  display: flex;
  gap: 0.6rem;
}

.checklist li::before {
  content: "✔";
  color: #10b981;
}

.concierge {
  margin-top: 2.5rem;
  background: #eef2ff;
  padding: 1.5rem;
  border-radius: 16px;
  display: grid;
  gap: 0.5rem;
}

.conditional {
  display: none;
  margin-top: 1rem;
}

.conditional.visible {
  display: block;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .container {
    padding: 2rem 1rem 4rem;
  }

  .panel {
    padding: 1.5rem;
  }

  .option-group {
    flex-direction: column;
  }

  .slider {
    flex-direction: column;
    align-items: flex-start;
  }

  button {
    width: 100%;
  }
}

.cycle-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.cycle-form {
  display: grid;
  gap: 1.25rem;
}

.cycle-form input[type="number"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.mini {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  margin-left: auto;
}

.slider.with-action {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.cycle-results {
  background: #f8f9fb;
  border-radius: 16px;
  padding: 1.5rem;
  display: grid;
  gap: 1.5rem;
}

.cycle-summary strong {
  font-size: 1.4rem;
}

.cycle-funnel {
  display: grid;
  gap: 0.75rem;
}

.funnel-stage {
  background: white;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  display: grid;
  gap: 0.35rem;
  position: relative;
}

.funnel-stage .label {
  font-weight: 600;
}

.funnel-stage .bar {
  height: 10px;
  border-radius: 999px;
  background: #e0e7ff;
  overflow: hidden;
}

.funnel-stage .bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.funnel-stage .details {
  font-size: 0.9rem;
  color: var(--muted);
}

.funnel-stage .tip {
  font-size: 0.85rem;
  color: var(--muted);
}

.funnel-stage .label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: help;
  transition: transform 0.2s ease;
  position: relative;
}

.info-icon:hover {
  transform: scale(1.15);
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: #1f2933;
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: normal;
  max-width: 280px;
  width: max-content;
  line-height: 1.5;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  display: none;
  transition: opacity 0.2s ease, visibility 0.2s ease, display 0.2s ease allow-discrete;
  white-space: normal;
}

.info-icon:hover::after {
  opacity: 1;
  visibility: visible;
  display: block;
}

.flag-picker label {
  min-width: 11rem;
  justify-content: flex-start;
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(31, 41, 51, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-content {
  background: var(--card);
  border-radius: 20px;
  padding: 2.5rem;
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  animation: modalSlideIn 0.3s ease;
}

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

.modal-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: transparent;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  background: #f1f4f8;
  color: var(--fg);
}

.modal h2 {
  margin-top: 0;
}

.modal input[type="email"],
.modal textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 1rem;
  font-family: inherit;
  margin-top: 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal input[type="email"]:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.modal textarea {
  resize: vertical;
  min-height: 100px;
}

.profile-preview {
  background: #f8f9fb;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-top: 0.5rem;
}

.modal label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
}

.modal input[type="checkbox"] {
  accent-color: var(--accent);
}
