:root {
  --ink: #3A2955;
  --muted: #5e6478;
  --brand: #25AA92;
  --brand-dark: #3A2955;
  --accent: #6CA2CB;
  --surface: #ffffff;
  --soft: #edf6f4;
  --line: #d6e5e4;
  --shadow: 0 16px 45px rgb(58 41 85 / 12%);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #f7f9f9;
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2.5rem;
  min-height: 82px;
  padding: .7rem max(1rem, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid #d9e2e1;
  background: #E9EFEE;
  backdrop-filter: blur(14px);
}

.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { display: block; width: min(205px, 42vw); height: auto; }

nav { display: flex; align-items: center; gap: .3rem; }
nav a { padding: .58rem .85rem; border-radius: .55rem; color: var(--brand-dark); text-decoration: none; font-size: .92rem; font-weight: 700; transition: color .2s ease, background .2s ease, transform .2s ease; }
nav a.active { color: white; background: var(--brand-dark); box-shadow: 0 4px 12px rgb(58 41 85 / 18%); }
nav a.external-link { border: 1px solid rgb(58 41 85 / 24%); }
nav a:hover { color: var(--brand-dark); background: rgb(108 162 203 / 18%); }
nav a.active:hover { color: white; background: #4b376c; transform: translateY(-1px); }
.menu-button { display: none; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 53%);
  align-items: center;
  max-width: 1440px;
  min-height: clamp(390px, 34vw, 520px);
  margin: clamp(1rem, 2vw, 2rem) auto 0;
  padding: clamp(3rem, 6vw, 6.5rem) clamp(1.5rem, 7vw, 7rem);
  overflow: hidden;
  border-radius: 1.5rem;
  color: white;
  background-image: linear-gradient(90deg, rgb(6 43 153 / 28%) 0%, rgb(0 91 200 / 8%) 48%, transparent 75%), url("./header-tools.jpg");
  background-position: center;
  background-size: cover;
  box-shadow: 0 1.25rem 3.5rem rgb(12 70 160 / 22%);
}

.eyebrow {
  margin: 0 0 .65rem;
  color: var(--brand);
  font-size: .94rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 { max-width: 780px; margin: 0; font-size: clamp(2.2rem, 4.6vw, 4.35rem); line-height: 1.08; letter-spacing: -.045em; }
h2 { margin: 0; font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1.05; letter-spacing: -.035em; }
.hero .eyebrow { color: #9cefe2; }
.hero h1 { max-width: 550px; text-wrap: balance; text-shadow: 0 .15rem .75rem rgb(0 24 98 / 28%); }
.hero-copy { max-width: 650px; margin: 1rem 0 0; color: white; font-size: clamp(.82rem, 1.2vw, .98rem); line-height: 1.5; font-weight: 600; text-shadow: 0 .1rem .5rem rgb(0 24 98 / 30%); }
.hero-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 2rem; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: .72rem 1rem;
  border: 1px solid transparent;
  border-radius: .75rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 750;
}
.button.primary { color: white; background: var(--brand-dark); box-shadow: 0 7px 16px rgb(58 41 85 / 18%); }
.button.primary:hover { background: #4b376c; }
.button.secondary { border-color: var(--line); color: var(--brand); background: white; }
.button.secondary:hover { background: var(--soft); }
.hero .button.primary { color: var(--brand-dark); background: white; box-shadow: 0 .5rem 1.5rem rgb(0 32 108 / 25%); }
.hero .button.primary:hover { color: white; background: var(--brand-dark); }
.hero .button.secondary { border-color: rgb(255 255 255 / 70%); color: white; background: rgb(16 53 139 / 32%); backdrop-filter: blur(6px); }
.hero .button.secondary:hover { color: var(--brand-dark); background: white; }

.hero-card {
  position: relative;
  padding: 1.8rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero-card::after {
  position: absolute;
  right: -3rem;
  bottom: -4rem;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  background: rgb(108 162 203 / 25%);
  content: "";
}
.hero-card p { position: relative; z-index: 1; margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.status-dot { display: inline-block; width: .6rem; height: .6rem; margin-right: .4rem; border-radius: 50%; background: var(--accent); }

.section { max-width: 1180px; margin: auto; padding: 5rem 1rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.search input {
  width: min(330px, 100%);
  padding: .78rem .9rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  color: var(--ink);
  background: white;
}
.search input:focus, input:focus, select:focus { outline: 3px solid rgb(37 170 146 / 20%); border-color: var(--brand); }

.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.tool-group { margin-top: 2.5rem; }
.tool-group:first-child { margin-top: 0; }
.tool-group h3 { margin: 0 0 1rem; color: var(--brand-dark); font-size: 1.25rem; }
.converter-group { margin-top: 4.5rem; padding-top: 2rem; border-top: 2px solid var(--line); }
.catalog-section-header { margin-bottom: 1.4rem; }
.catalog-section-header .eyebrow { margin-bottom: .35rem; }
.catalog-section-header h2 { margin: 0; color: var(--brand-dark); font-size: clamp(1.75rem, 4vw, 2.4rem); }
.catalog-section-header p:last-child { max-width: 650px; margin: .55rem 0 0; color: var(--muted); line-height: 1.5; }
.tool-card {
  position: relative;
  display: grid;
  min-height: 215px;
  padding: 1.45rem;
  overflow: hidden;
  border: 1px solid rgb(108 162 203 / 27%);
  border-radius: 1.15rem;
  color: var(--ink);
  text-align: left;
  background: linear-gradient(145deg, white 0%, #f4f9fa 100%);
  box-shadow: 0 .7rem 1.8rem rgb(40 67 111 / 8%);
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.tool-card::before { position: absolute; top: 0; right: 0; left: 0; height: .28rem; background: linear-gradient(90deg, var(--brand), #2399d5); content: ""; }
button.tool-card { cursor: pointer; }
button.tool-card:hover { transform: translateY(-5px); border-color: var(--brand); color: white; background: var(--brand); box-shadow: 0 1.25rem 2.4rem rgb(37 170 146 / 28%); }
button.tool-card:hover::before { background: white; }
button.tool-card:hover .tool-icon { border-color: rgb(255 255 255 / 42%); color: var(--brand); background: white; box-shadow: none; }
button.tool-card:hover > span:last-child { color: white; }
.tool-card strong { align-self: end; margin-bottom: .45rem; font-size: 1.16rem; line-height: 1.22; }
.tool-card > span:last-child { color: var(--muted); line-height: 1.45; }
.tool-card.muted { background: #f5f8f7; box-shadow: none; }
.tool-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  border: 1px solid rgb(37 170 146 / 16%);
  border-radius: .9rem;
  color: white;
  background: linear-gradient(135deg, var(--brand), #278ed1);
  box-shadow: 0 .5rem 1rem rgb(37 170 146 / 20%);
  font-weight: 850;
}
.tag { position: absolute; top: 1.3rem; right: 1.3rem; padding: .3rem .5rem; border-radius: 999px; font-size: .66rem; font-weight: 850; text-transform: uppercase; }
.tag.available { display: none; }
.tag.planned { color: #6f6555; background: #eeeae1; }

.calculator-shell { max-width: 900px; margin: auto; padding: 2rem 1rem 6rem; }
.back-link { margin-bottom: 1rem; border: 0; color: var(--brand); background: transparent; cursor: pointer; font-weight: 750; }
.calculator-card { padding: clamp(1.2rem, 4vw, 2.3rem); border: 1px solid var(--line); border-radius: 1.2rem; background: white; box-shadow: var(--shadow); }
.notice { padding: .85rem 1rem; border-left: 4px solid var(--accent); color: #645536; background: #fff8e9; line-height: 1.45; }
.install-dialog { width: min(31rem, calc(100% - 2rem)); padding: 0; border: 0; border-radius: 1rem; color: var(--ink); background: white; box-shadow: 0 1.25rem 4rem rgb(24 18 34 / 28%); }
.install-dialog::backdrop { background: rgb(22 16 31 / 48%); }
.install-dialog-content { position: relative; padding: 1.5rem 3.5rem 1.5rem 1.5rem; }
.install-dialog h2 { margin: .25rem 0 .7rem; color: var(--brand-dark); }
.install-dialog-message > p { margin: 0; line-height: 1.55; }
.install-steps { display: grid; gap: .65rem; margin: 1rem 0; padding-left: 1.4rem; line-height: 1.45; }
.install-steps li::marker { color: var(--brand); font-weight: 850; }
.install-note { padding: .8rem .9rem; border-left: 3px solid var(--brand); border-radius: .35rem; color: #31584f; background: var(--soft); font-size: .92rem; }
.dialog-close { position: absolute; top: .8rem; right: .8rem; display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border: 0; border-radius: 50%; color: var(--brand); background: var(--soft); font-size: 1.4rem; cursor: pointer; }
.dialog-close:hover { background: #dce7e4; }
form { display: grid; gap: 1rem; margin-top: 1.5rem; }
form label { display: grid; gap: .4rem; font-weight: 700; }
form input, form select { width: 100%; padding: .78rem .85rem; border: 1px solid var(--line); border-radius: .65rem; color: var(--ink); background: white; }
form .button { justify-self: start; }
.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-section { margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; }
.form-section legend { padding: 0 .45rem; color: var(--brand); font-weight: 850; }
.clinical-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
form label small { color: var(--muted); font-size: .75rem; font-weight: 500; line-height: 1.35; }
.check-label { display: flex; flex-direction: row; align-items: center; align-self: end; min-height: 2.9rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: .65rem; }
.check-label input { width: auto; margin: 0 .6rem 0 0; }
.check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.live-calculation { display: grid; align-content: center; gap: .25rem; min-height: 100%; padding: .8rem; border: 1px solid var(--line); border-radius: .65rem; color: var(--brand-dark); background: var(--soft); }
.live-calculation span { font-weight: 700; }
.live-calculation strong { font-size: 1.25rem; }
.live-calculation small { color: var(--muted); }
.data-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; margin-top: .8rem; }
.data-summary span { padding: .65rem; border: 1px solid rgb(37 170 146 / 16%); border-radius: .6rem; background: white; }
.crisis-results { display: grid; gap: 1rem; margin-top: 1.3rem; }
.classification-card { padding: 1.2rem; border: 1px solid var(--brand); border-radius: .9rem; color: var(--brand-dark); background: var(--soft); }
.classification-card strong { display: block; margin-bottom: .35rem; font-size: 1.25rem; }
.result-section { padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; background: white; }
.result-section h3 { margin: 0 0 .8rem; color: var(--brand-dark); }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.metric { padding: .7rem; border-radius: .65rem; background: var(--soft); }
.metric b, .criterion b { display: block; margin-bottom: .18rem; }
.metric small, .criterion small { color: var(--muted); }
.criteria-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.criterion { padding: .7rem .8rem; border-left: 4px solid var(--line); border-radius: .45rem; background: #f8faf9; }
.criterion.met { border-left-color: #239873; }
.criterion.not-met { border-left-color: #c98b31; }
.criterion.unknown { border-left-color: #84969a; }
.clinical-warning { padding: .85rem 1rem; border-left: 4px solid #b36b2c; color: #68461f; background: #fff5e8; line-height: 1.45; }
.treatment-alert { display: grid; gap: .25rem; margin-bottom: 1rem; padding: .85rem 1rem; border-left: 5px solid; border-radius: .6rem; }
.treatment-alert.ready { border-color: #239873; color: #075c48; background: #e5f5ef; }
.treatment-alert.blocked { border-color: #be553f; color: #812e20; background: #f9e6e2; }
.treatment-grid { margin-top: .8rem; }
.protocol-plan { padding: .8rem; border-radius: .65rem; background: var(--soft); line-height: 1.45; }
.reference-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: .8rem; }
.reference-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.reference-table th, .reference-table td { padding: .7rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.reference-table th { color: var(--brand-dark); background: var(--soft); font-size: .8rem; }
.reference-table tr:last-child td { border-bottom: 0; }
.reference-table tr.normal td:first-child { border-left: 5px solid #239873; }
.reference-table tr.abnormal td:first-child { border-left: 5px solid #be553f; }
.reference-table tr.unknown td:first-child { border-left: 5px solid #84969a; }
.reference-value { font-weight: 850; white-space: nowrap; }
.reference-status { display: inline-block; margin-top: .25rem; padding: .18rem .42rem; border-radius: 999px; font-size: .68rem; font-weight: 850; text-transform: uppercase; }
.reference-status.normal { color: #075c48; background: #dff4ed; }
.reference-status.abnormal { color: #8b3324; background: #f9e3de; }
.reference-status.unknown { color: #52676b; background: #e8eeee; }
.result { margin-top: 1.3rem; padding: 1rem; border-radius: .8rem; color: var(--brand-dark); background: var(--soft); line-height: 1.5; }
.result strong { display: block; font-size: 1.35rem; }
.result span, .result small { display: block; margin-top: .25rem; }
.result small { color: var(--muted); }
.measurements { display: grid; gap: .7rem; }
.measurement-row { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: .7rem; align-items: end; margin: 0; padding: .8rem; border: 1px solid var(--line); border-radius: .8rem; }
.measurement-number { align-self: center; color: var(--brand); font-weight: 850; }
.method-hint { margin: 0; color: var(--muted); font-size: .9rem; }
.remove-measurement { min-width: 2.8rem; min-height: 2.8rem; border: 1px solid var(--line); border-radius: .65rem; color: #a12f2f; background: white; cursor: pointer; font-weight: 800; }
.remove-measurement:disabled { cursor: not-allowed; opacity: .35; }
.remove-measurement { min-width: 2.8rem; min-height: 2.8rem; border: 1px solid var(--line); border-radius: .65rem; color: #a12f2f; background: white; cursor: pointer; font-weight: 800; }
.form-actions { display: flex; flex-wrap: wrap; gap: .7rem; }

.soft-section { max-width: none; padding-right: max(1rem, calc((100vw - 1180px) / 2)); padding-left: max(1rem, calc((100vw - 1180px) / 2)); background: var(--soft); }
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.info-grid article { padding: 1.3rem; border-radius: 1rem; background: white; }
.info-grid p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }

footer { display: flex; justify-content: space-between; align-items: center; gap: 2rem; padding: 1.5rem max(1rem, calc((100vw - 1180px) / 2)); color: white; background: #25AA92; font-size: .85rem; }
.footer-disclaimer { max-width: 900px; line-height: 1.45; }
.footer-links { display: flex; flex: 0 0 auto; align-items: center; gap: .55rem; }
.footer-contact { flex: 0 0 auto; padding: .62rem .9rem; border: 1px solid white; border-radius: .55rem; color: white; text-decoration: none; font-weight: 750; transition: background .2s ease, color .2s ease; }
.footer-contact:hover { color: var(--brand-dark); background: white; }
.social-link { display: grid; width: 2.55rem; height: 2.55rem; place-items: center; border: 1px solid rgb(255 255 255 / 72%); border-radius: .55rem; color: white; transition: color .2s ease, background .2s ease, transform .2s ease; }
.social-link:hover { color: var(--brand-dark); background: white; transform: translateY(-2px); }
.social-link svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.social-link .youtube-play { fill: currentColor; stroke: none; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 801px) {
  .hero { grid-template-columns: minmax(0, 60%); }
  .hero h1 { max-width: none; font-size: clamp(2.25rem, 3vw, 3.25rem); white-space: nowrap; }
}

@media (max-width: 800px) {
  .site-header { flex-wrap: wrap; }
  .menu-button { display: block; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .6rem; color: var(--brand); background: white; font-weight: 750; }
  nav { display: none; flex-basis: 100%; flex-direction: column; }
  nav.open { display: flex; }
  .site-header { gap: 1rem; }
  nav { gap: .3rem; }
  nav a.external-link { width: 100%; }
  .hero { grid-template-columns: minmax(0, 60%); min-height: 440px; padding-top: 3.5rem; padding-bottom: 3.5rem; background-position: 63% center; }
  .tool-grid, .info-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .hero { grid-template-columns: 1fr; min-height: 465px; padding-bottom: 3rem; border-radius: 0; background-image: linear-gradient(90deg, rgb(6 43 153 / 86%) 0%, rgb(0 91 200 / 68%) 100%), url("./header-tools.jpg"); background-position: 48% center; }
  h1 { font-size: 2.7rem; }
  .section { padding-top: 3.5rem; padding-bottom: 3.5rem; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .search input { width: 100%; }
  .tool-grid, .info-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; align-items: flex-start; }
  .measurement-row { grid-template-columns: 1fr; }
  .form-columns { grid-template-columns: 1fr; }
  .clinical-grid, .data-summary, .result-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .remove-measurement { width: 100%; }
}

@media (min-width: 561px) and (max-width: 900px) {
  .clinical-grid, .data-summary, .result-grid { grid-template-columns: 1fr 1fr; }
}
