html,
body {
  min-height: 100%;
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f4f6f8;
  color: #1f2933;
}

body.app-page {
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  min-height: 0;
}

.sidebar {
  width: 240px;
  background: #2c3e50;
  color: white;
  padding: 20px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.sidebar-brand {
  text-align: center;
  margin-bottom: 28px;
}

.sidebar-brand img {
  width: 110px;
  margin-bottom: 10px;
}

.sidebar-brand h1 {
  font-size: 1.35rem;
  margin: 0;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
}

.nav-button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #34495e;
  color: white;
  cursor: pointer;
  text-align: left;
}

.nav-button-home {
  margin-bottom: 18px;
  text-align: center;
}

.nav-button:hover:not(:disabled),
.nav-button.active {
  background: #0a9bb0;
}

.nav-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.patient-header {
  background: white;
  padding: 18px;
  border-bottom: 1px solid #ddd;
}

.patient-header h2 {
  margin-top: 0;
}

.patient-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 16px;
  align-items: end;
}

.weight-field {
  max-width: 140px;
}

.procedure-field {
  grid-column: span 2;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 7px;
  box-sizing: border-box;
}

.button-row {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
}

button {
  padding: 10px 18px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
}

.content-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
}

.calculator-page {
  display: grid;
  gap: 20px;
  padding: 0 18px;
}

.calculator-header {
  background: white;
  padding: 24px;
  border-radius: 12px;
}

.calculator-header h2 {
  margin: 0 0 8px;
}

.calculator-header p {
  margin: 0;
  color: #52616b;
}

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 20px;
}

.calculator-card {
  background: white;
  padding: 18px;
  border-radius: 12px;
}

.calculator-card h3 {
  margin-top: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 12px;
}

.result-tile {
  background: #f4f6f8;
  padding: 16px;
  border-radius: 10px;
}

.result-label,
.result-unit {
  display: block;
  color: #52616b;
  font-size: 0.85rem;
}

.result-tile strong {
  display: block;
  font-size: 1.8rem;
  margin: 8px 0 4px;
}

.form-row {
  display: grid;
  gap: 12px;
}

.form-row-compact {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.field-warning {
  display: block;
  min-height: 1rem;
  margin-top: 4px;
  color: #b45309;
  font-size: 0.8rem;
  font-weight: 600;
}

.search-results:empty {
  display: none;
}

.search-field {
  position: relative;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;

  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-top: 4px;

  max-height: 240px;
  overflow-y: auto;
}

.search-results option,
.search-results div {
  padding: 8px;
  cursor: pointer;
  color: #1f2933;
  background: white;
}

.search-results option:hover,
.search-results div:hover {
  background: #f4f6f8;
}

.food-row {
  grid-template-columns: minmax(260px, 1fr) 110px;
  align-items: start;
}

.display-field {
  background: #f4f6f8;
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 38px;
}

.display-label {
  display: block;
  color: #52616b;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.display-field strong {
  display: block;
  font-size: 1rem;
}

/*
 * Only the currently selected calculator page is displayed.
 */
.page {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 0;
}

.page.active {
  display: block;
}


/*
 * Emergency Drugs breathing-circuit row
 */
.emergency-circuit-row {
  display: grid;
  grid-template-columns:
    minmax(220px, 1fr)
    minmax(150px, 180px)
    minmax(180px, 220px);
  gap: 14px;
  align-items: stretch;
}

.emergency-circuit-select {
  align-self: start;
}

.emergency-result-tile {
  min-height: 72px;
  box-sizing: border-box;
}

.emergency-result-tile strong {
  margin-bottom: 0;
}

.emergency-drugs-button-row {
  justify-content: flex-end;
}


/*
 * Allow the result tiles to move below the circuit selector
 * on narrower screens.
 */
@media (max-width: 760px) {
  .emergency-circuit-row {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .emergency-circuit-select {
    grid-column: 1 / -1;
  }
}


/*
 * Stack everything vertically on very narrow screens.
 */
@media (max-width: 520px) {
  .emergency-circuit-row {
    grid-template-columns: 1fr;
  }

  .emergency-circuit-select {
    grid-column: auto;
  }

  .emergency-drugs-button-row {
    justify-content: stretch;
  }

  .emergency-drugs-button-row button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .food-row {
    grid-template-columns: 1fr;
  }

  .kcal-display-field {
    max-width: 120px;
  }
}

@media (max-width: 520px) {
  .form-row-compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .calculator-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .patient-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .procedure-field {
    grid-column: span 2;
  }
}

@media (max-width: 520px) {
  .patient-grid {
    grid-template-columns: 1fr;
  }

  .weight-field {
    max-width: none;
  }

  .procedure-field {
    grid-column: span 1;
  }
}



.landing-page {
  min-height: 100vh;
  height: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  overflow-y: auto;
  background: linear-gradient(135deg, #eef6f8, #f7f9fb);
}

.landing-card {
  margin: auto 0;
  background: #ffffff;
  max-width: 620px;
  width: 100%;
  padding: 38px 42px 34px;
  border-radius: 22px;
  text-align: center;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
}

.landing-logo {
  width: 170px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #0a9bb0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.landing-card h1 {
  margin: 0 0 12px;
  font-size: 2.1rem;
}

.tagline {
  font-size: 1.08rem;
  line-height: 1.5;
  margin: 0 0 28px;
}

.feature-list {
  display: grid;
  gap: 10px;
  margin: 0 auto 28px;
  max-width: 430px;
  text-align: left;
}

.feature {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f6f8;
  color: #52616b;
}

.feature::before {
  content: "Coming soon";
  display: inline-block;
  min-width: 100px;
  margin-right: 10px;
  color: #7b8794;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.feature.ready::before {
  content: "Testing";
  color: #0a9bb0;
}

.status {
  margin: 0;
  font-size: 0.92rem;
  color: #0a9bb0;
  font-weight: 700;
}

@media (max-width: 600px) {
  .landing-card {
    padding: 40px 24px;
  }

  h1 {
    font-size: 2.1rem;
  }

  .landing-logo {
    width: 140px;
  }

  .feature::before {
    display: block;
    margin-bottom: 4px;
  }
}

.beta-access-section {
  margin: 1.1rem auto 0;
  padding-top: 0.8rem;
  max-width: 360px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
}

.beta-access-section h2 {
  margin: 0 0 0.3rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: #0a9bb0;
  font-weight: 700;
}

.beta-code-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.beta-code-box input {
  padding: 0.45rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.8rem;
}

.beta-code-box button {
  padding: 0.55rem;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.beta-code-message {
  margin-top: 0.75rem;
  font-size: 0.78rem;
}

.beta-access-section p {
  margin: 0 0 0.45rem;
  line-height: 1.2;
  font-size: 0.78rem;
}

.beta-code-box label {
  font-size: 0.72rem;
  font-weight: 600;
}


.beta-terms-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.beta-terms-card {
  width: 100%;
  max-width: 430px;
  background: #ffffff;
  border-radius: 22px;
  padding: 42px 42px 46px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

.beta-terms-logo {
  width: 120px;
  margin-bottom: 18px;
}

.beta-terms-card p {
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 14px;
}

.beta-terms-check {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 12px;
    margin: 28px 0 26px;
    cursor: pointer;
}

.beta-terms-check input {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex-shrink: 0;
}

.beta-terms-check label {
    max-width: 420px;
    margin: 0;
    text-align: left;
    line-height: 1.35;
    cursor: pointer;
}

#betaTermsContinue {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-top: 8px;
}

#betaTermsContinue:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.beta-terms-overlay.hidden {
  display: none;
}

.app-footer {
  margin-top: 0;
  padding: 10px 22px;
  border-top: 1px solid #d8dee8;
  background: #f8fafc;
  text-align: left;
  flex-shrink: 0;
}

.footer-disclaimer {
  margin: 0 0 6px;
  font-size: 0.75rem;
  color: #5f6b7a;
  line-height: 1.4;
}

.footer-version {
  margin: 0 0 6px;
  font-size: 0.75rem;
  color: #5f6b7a;
  line-height: 1.4;
}

.footer-copyright {
  margin: 0;
  font-size: 0.7rem;
  color: #8893a3;
}

.coming-soon-page {
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef6f8, #f7f9fb);
}

.coming-soon-card {
  width: 100%;
  max-width: 620px;
  background: #ffffff;
  border-radius: 22px;
  padding: 44px 42px;
  text-align: center;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
}

.coming-soon-logo {
  width: 160px;
  margin-bottom: 18px;
}

.coming-soon-card h1 {
  margin: 0 0 18px;
  font-size: 2rem;
  line-height: 1.2;
}

.coming-soon-intro {
  margin: 0 auto 28px;
  max-width: 500px;
  line-height: 1.5;
  color: #52616b;
}

.coming-soon-features {
  display: grid;
  gap: 10px;
  margin: 0 auto 30px;
  max-width: 430px;
}

.coming-soon-features div {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f6f8;
  color: #52616b;
}

.beta-access-button {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 10px;
  background: #0a9bb0;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.beta-access-button:hover {
  background: #087f91;
}


.home-page {
  width: 100%;
  padding: 18px;
  box-sizing: border-box;
}

.home-hero {
  padding: 2rem;
  margin-bottom: 1.5rem;
  background: var(--surface, #ffffff);
  border-radius: 0.75rem;
}

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

.home-introduction {
  max-width: 50rem;
  font-size: 1.1rem;
  line-height: 1.6;
}

.home-calculator-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(min(100%, 16rem), 1fr)
  );
  gap: 1rem;
}

.home-calculator-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 10rem;
  padding: 1.5rem;
  text-align: left;
  background: var(--surface, #ffffff);
  border: 1px solid #d8dee6;
  border-radius: 0.75rem;
  cursor: pointer;
}

.home-calculator-card:hover,
.home-calculator-card:focus-visible {
  border-color: currentColor;
  transform: translateY(-2px);
}

.home-calculator-title {
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.home-calculator-description {
  line-height: 1.5;
}

/*
 * Hypotension infusion setup
 */

.hypotension-setup-grid {
  display: grid;
  grid-template-columns:
    minmax(150px, 190px)
    minmax(150px, 190px)
    minmax(190px, 230px);
  gap: 18px;
  align-items: end;
  justify-content: start;
}

.hypotension-setup-field {
  min-width: 0;
}

.hypotension-setup-field select {
  width: 100%;
}

.hypotension-rate-display {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 54px;
  padding: 6px 10px;
  box-sizing: border-box;
}

.hypotension-value-with-unit {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 20px;
}

.hypotension-rate-display .display-label {
  margin-bottom: 2px;
}

.hypotension-value-with-unit strong {
  display: inline;
  font-size: 1.1rem;
}

.hypotension-value-with-unit span {
  color: #52616b;
  font-size: 0.85rem;
}

.hypotension-input-with-unit {
  display: grid;
  grid-template-columns: minmax(80px, 130px) auto;
  gap: 7px;
  align-items: center;
  margin-top: 6px;
}

.hypotension-input-with-unit input {
  width: 100%;
  margin-top: 0;
}

.hypotension-input-with-unit span {
  white-space: nowrap;
  color: #52616b;
  font-size: 0.85rem;
}

.hypotension-setup-card .field-help {
  margin: 14px 0 0;
  color: #52616b;
  font-size: 0.85rem;
}

.hypotension-button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/*
 * Hypotension drug-result layout
 *
 * Default to a single column. Only switch directly to
 * three columns when there is enough horizontal space.
 */

.hypotension-drug-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.hypotension-drug-card {
  min-width: 0;
}


/*
 * At wider viewport sizes, show all three drugs side by side.
 * There is deliberately no two-column intermediate layout.
 */
@media (min-width: 1100px) {
  .hypotension-drug-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }
}

@media (max-width: 760px) {
  .hypotension-setup-grid {
    grid-template-columns:
      minmax(140px, 1fr)
      minmax(140px, 1fr);
  }

  .hypotension-setup-field:last-child {
    grid-column: 1 / -1;
    max-width: 230px;
  }
}

@media (max-width: 520px) {
  .hypotension-setup-grid {
    grid-template-columns: 1fr;
  }

  .hypotension-setup-field:last-child {
    grid-column: auto;
    max-width: none;
  }

  .hypotension-input-with-unit {
    grid-template-columns: minmax(80px, 1fr) auto;
  }

  .hypotension-button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hypotension-button-row button {
    width: 100%;
  }
}

@media (min-width: 1100px) {
  .hypotension-drug-card {
    display: flex;
    flex-direction: column;
  }

  .hypotension-key-results {
    margin-top: auto;
  }
}

/*
 * Visually separate Home from the calculator navigation.
 */
.sidebar-nav > button:first-child {
  margin-bottom: 32px;
}