:root {
  color-scheme: light;
  --ink: #152323;
  --muted: #5d6c6c;
  --header: #102c2e;
  --header-soft: #183c3e;
  --brand: #087f73;
  --brand-dark: #056158;
  --brand-soft: #e1f3ef;
  --accent: #d9a528;
  --surface: #ffffff;
  --surface-2: #f4f7f6;
  --line: #d8e0de;
  --line-strong: #bdcbc8;
  --shadow: 0 7px 24px rgba(20, 48, 46, 0.07);
  --radius: 14px;
  --status-height: 38px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  padding-bottom: var(--status-height);
  background: var(--surface-2);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

button, select { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(217, 165, 40, 0.6);
  outline-offset: 2px;
}

.site-header {
  position: relative;
  z-index: 10;
  background:
    radial-gradient(circle at 90% -40%, rgba(78, 180, 165, 0.23), transparent 42%),
    var(--header);
  color: #f6fbfa;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.header-inner {
  width: min(1240px, calc(100% - 40px));
  min-height: 92px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.brand-block { display: flex; align-items: center; gap: 15px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--brand);
  color: white;
  font-size: 29px;
  font-weight: 300;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

.eyebrow {
  margin: 0 0 5px;
  color: #94bbb6;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow.accent { color: var(--brand); }

h1 { margin: 0; font-size: clamp(1.18rem, 2.4vw, 1.6rem); letter-spacing: -0.025em; }

.byline { margin: 4px 0 0; color: #9fc0bb; font-size: 0.74rem; font-weight: 600; }
.byline strong { color: #d7e6e3; font-weight: 750; }

.tabs { display: flex; align-self: stretch; gap: 6px; }

.tab {
  position: relative;
  min-width: 90px;
  border: 0;
  background: transparent;
  color: #b8cfcc;
  font-weight: 750;
}

.tab:hover { color: white; }

.tab.is-active { color: white; }

.tab.is-active::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

.header-note {
  margin: 0;
  padding: 7px 20px;
  background: rgba(0,0,0,.16);
  color: #bdd2cf;
  text-align: center;
  font-size: 0.76rem;
}

.controls-wrap {
  position: sticky;
  top: 0;
  z-index: 8;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
}

.controls {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  align-items: end;
  gap: 14px;
}

.control-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.control-group > span:first-child,
.control-group > legend {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.search-group { flex: 1 1 290px; }
.specialty-group { flex: 0 1 240px; }
.scheme-group, .edition-group, .tier-group { flex: 0 0 auto; }

.segmented {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.segment {
  min-height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 750;
  white-space: nowrap;
}

.segment:hover { color: var(--ink); }

.segment.is-active {
  background: var(--header);
  color: white;
  box-shadow: 0 2px 7px rgba(16,44,46,.2);
}

.compact .segment { padding-inline: 12px; }
.tier-segments .segment span { opacity: .7; }

.search-shell { position: relative; display: block; }

.search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  transform: translateY(-54%);
  color: var(--muted);
  font-size: 1.3rem;
}

input, select {
  width: 100%;
  height: 47px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}

input { padding: 0 14px 0 40px; }
select { padding: 0 36px 0 13px; }
input::placeholder { color: #879491; }
input:hover, select:hover { border-color: #8ca29e; }

.results-shell {
  width: min(1160px, calc(100% - 40px));
  min-height: 50vh;
  margin: 0 auto;
  padding: 30px 0 56px;
}

.results-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
}

.context-label {
  margin: 0 0 3px;
  color: var(--brand);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.results-heading h2 { margin: 0; font-size: 1rem; font-weight: 650; }

.narrow-hint {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
}

.card-grid { display: grid; gap: 10px; }

.package-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 18px 20px;
}

.card-copy { min-width: 0; }

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.code-badge, .tier-badge, .chip {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .025em;
}

.code-badge { background: var(--brand-soft); color: var(--brand-dark); }
.tier-badge { border: 1px solid var(--line); color: var(--muted); }
.chip { background: #fff5d9; color: #73540a; }

.whatsapp-share {
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 5px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, #25D366 45%, var(--line));
  border-radius: 50%;
  background: transparent;
  color: #25D366;
  line-height: 0;
}

.whatsapp-share:hover { background: color-mix(in srgb, #25D366 12%, transparent); }
.whatsapp-share svg { width: 100%; height: 100%; fill: currentColor; }

.package-title { margin: 0; font-size: 1rem; line-height: 1.35; }

.procedure-name, .specialty-name {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.4;
}

.specialty-name { color: var(--brand); font-weight: 650; }

.rate-side { min-width: 132px; text-align: right; }

.rate-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.primary-rate { color: var(--brand-dark); font-size: 1.15rem; font-weight: 850; white-space: nowrap; }
.rule-rate { display: inline-block; max-width: 155px; font-size: .82rem; white-space: normal; }

.rates {
  display: grid;
  grid-template-columns: repeat(3, minmax(88px, auto));
  gap: 8px;
}

.rates.two { grid-template-columns: repeat(2, minmax(100px, auto)); }

.rate-box {
  min-width: 0;
  padding: 9px 11px;
  border-left: 1px solid var(--line);
  text-align: right;
}

.rate-box strong { color: var(--brand-dark); font-size: .97rem; white-space: nowrap; }

.detail-toggle {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 68%, var(--surface));
}

.detail-toggle summary {
  padding: 10px 20px;
  color: var(--brand-dark);
  font-size: .78rem;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.detail-toggle summary::-webkit-details-marker { display: none; }
.detail-toggle summary::before { content: "+"; display: inline-block; width: 18px; font-size: 1rem; }
.detail-toggle[open] summary::before { content: "−"; }

.detail-body { padding: 5px 20px 20px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.detail-item { margin: 0; }
.detail-item.wide { grid-column: 1 / -1; }
.detail-item dt { color: var(--muted); font-size: .67rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.detail-item dd { margin: 4px 0 0; font-size: .84rem; line-height: 1.5; }

.flag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.flag-state { padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: .72rem; }
.flag-state.yes { border-color: #9cc9c0; background: var(--brand-soft); color: var(--brand-dark); }

.tier-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.tier-table th, .tier-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.tier-table th:first-child, .tier-table td:first-child { text-align: left; }
.tier-table thead th { color: var(--muted); font-size: .67rem; letter-spacing: .04em; text-transform: uppercase; }
.tier-table tbody tr:last-child td { border-bottom: 0; }
.tier-table .selected-row { background: var(--brand-soft); }

.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state h2 { margin: 10px 0 4px; color: var(--ink); font-size: 1.1rem; }
.empty-state p { margin: 0; font-size: .88rem; }
.empty-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--surface); font-size: 1.5rem; }
.load-sentinel { height: 2px; }

.about-panel {
  width: min(850px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.about-card {
  padding: clamp(25px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.about-card h2 { margin: 0 0 16px; font-size: clamp(1.5rem, 4vw, 2.2rem); line-height: 1.14; letter-spacing: -.035em; }
.about-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.7; }

.disclaimer {
  margin-top: 30px;
  padding: 22px;
  border-left: 4px solid var(--accent);
  border-radius: 5px 12px 12px 5px;
  background: #fff8e7;
}

.disclaimer h3 { margin: 0 0 8px; font-size: .92rem; }
.disclaimer p { margin: 0; color: #514722; font-size: .86rem; line-height: 1.65; }

.credits {
  margin-top: 20px;
  padding: 18px 22px;
  border-left: 4px solid var(--brand, #1f2d2b);
  border-radius: 5px 12px 12px 5px;
  background: #eef3f2;
}
.credits h3 { margin: 0 0 6px; font-size: .92rem; }
.credits p { margin: 0; font-size: .88rem; line-height: 1.6; color: #33403d; }

.status-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  height: var(--status-height);
  padding: 0 max(20px, calc((100% - 1240px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  color: var(--muted);
  backdrop-filter: blur(12px);
  font-size: .72rem;
}

[hidden] { display: none !important; }

@media (max-width: 1050px) {
  .controls { flex-wrap: wrap; }
  .search-group { order: 5; flex-basis: calc(60% - 7px); }
  .specialty-group { order: 6; flex: 1 1 calc(40% - 7px); }
}

@media (max-width: 740px) {
  .header-inner { width: min(100% - 28px, 1240px); min-height: 78px; align-items: center; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .eyebrow { display: none; }
  h1 { max-width: 240px; }
  .tab { min-width: 70px; }
  .controls, .results-shell { width: min(100% - 24px, 1240px); }
  .scheme-group { width: 100%; }
  .scheme-group .segmented, .scheme-group .segment { flex: 1; }
  .edition-group { flex: 1 1 auto; }
  .tier-group { width: 100%; }
  .tier-group .segmented, .tier-group .segment { flex: 1; min-width: 0; padding-inline: 5px; }
  .search-group, .specialty-group { flex-basis: 100%; }
  .card-main { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
  .rate-side { min-width: 0; text-align: left; }
  .rates { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rates.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rate-box { padding: 8px; border-left: 0; border-right: 1px solid var(--line); text-align: left; }
  .rate-box:last-child { border-right: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-item.wide { grid-column: auto; }
  .tier-table th, .tier-table td { padding: 8px 5px; font-size: .72rem; }
  .status-bar span:last-child { display: none; }
}

@media (max-width: 480px) {
  .brand-block { gap: 9px; }
  .brand-mark { display: none; }
  h1 { max-width: 190px; font-size: 1rem; }
  .header-note { padding-inline: 12px; font-size: .68rem; }
  .tab { min-width: 62px; font-size: .8rem; }
  .controls-wrap { position: static; }
  .results-shell { padding-top: 22px; }
  .results-heading { align-items: start; }
  .rates { gap: 0; }
  .rate-box strong { font-size: .85rem; }
  .rate-label { font-size: .57rem; }
  .narrow-hint { max-width: 90px; text-align: right; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e7efed;
    --muted: #9eaeab;
    --header: #0b2022;
    --header-soft: #133638;
    --brand: #31a999;
    --brand-dark: #69c9bb;
    --brand-soft: #173b38;
    --surface: #142120;
    --surface-2: #0d1818;
    --line: #293b39;
    --line-strong: #3b504d;
    --shadow: 0 8px 26px rgba(0,0,0,.2);
  }
  .chip { background: #3f361e; color: #f0ce76; }
  .disclaimer { background: #312c1e; }
  .disclaimer p { color: #e4dabd; }
  .credits { background: #202b29; }
  .credits p { color: #c9d6d3; }
  input::placeholder { color: #71817e; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
