:root{
  --app-radius:1rem;
  --app-blue:#0d6efd;
  --app-blue-soft:#eef5ff;
}
body{font-family:system-ui,-apple-system,"Segoe UI",Tahoma,sans-serif;color:#1f2937}
.app-shell{max-width:1120px}
.brand-icon{width:34px;height:34px;border-radius:10px;display:inline-grid;place-items:center;background:var(--app-blue-soft);color:var(--app-blue)}
.card{--bs-card-border-color:rgba(17,24,39,.06)}
.step-dot{width:28px;height:28px;border-radius:50%;display:inline-grid;place-items:center;background:var(--app-blue);color:#fff;font-weight:800;font-size:.85rem;flex:0 0 auto}
.form-label{margin-bottom:.45rem}
.input-group-text{background:#fff;color:#6b7280}
.form-control,.form-select,.select2-container--bootstrap-5 .select2-selection{border-radius:.75rem}
.input-group>.form-control:not(:last-child),.input-group>.form-select:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}
.input-group>.input-group-text:last-child{border-radius:0 .75rem .75rem 0}

.result-primary{background:linear-gradient(180deg,#f7fbff 0%,#eef5ff 100%);border:1px solid #dbeafe;border-radius:1rem;padding:1.25rem 1.4rem;display:flex;flex-direction:column;justify-content:center;min-height:160px}
.result-main{font-size:clamp(2rem,5vw,3.45rem);line-height:1.05;font-weight:850;letter-spacing:-.04em;color:#0b57d0}
.result-mg{font-size:clamp(1.15rem,2.5vw,1.5rem);font-weight:750;color:var(--bs-primary)}
.result-side{border:1px solid #e5e7eb;border-radius:1rem;padding:1.25rem;background:#fff;min-height:160px}

.selected-dose-readout{display:flex;justify-content:space-between;gap:12px;padding:.65rem .85rem;border-radius:.75rem;background:#f8fafc;border:1px solid #e5e7eb}
.selected-dose-readout strong{color:#0b57d0}
.summary-panel{background:linear-gradient(135deg,#172554 0%,#1e3a5f 100%);color:#f8fafc;border:1px solid rgba(255,255,255,.08);border-radius:1rem;padding:1rem 1.2rem;box-shadow:0 .75rem 1.75rem rgba(15,23,42,.18)}
.summary-panel .text-body-secondary{color:rgba(248,250,252,.68)!important}
.summary-dose{font-size:clamp(1.15rem,2.8vw,1.55rem);font-weight:800;line-height:1.35}
.metric-box{height:100%;border:1px solid #e5e7eb;border-radius:.9rem;padding:.9rem;background:#fff}
.metric-box-primary{background:#eef5ff;border-color:#cfe2ff}
.metric-label{font-size:.78rem;color:#6b7280;margin-bottom:.3rem}
.metric-value{font-size:clamp(.95rem,2vw,1.3rem);font-weight:800;line-height:1.2;overflow-wrap:anywhere}
.formula-box{white-space:pre-wrap;line-height:1.65}

.select2-container--bootstrap-5 .select2-selection--single{min-height:48px;padding:.62rem .75rem}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered{line-height:1.6}
.select2-container--bootstrap-5 .select2-dropdown{border-radius:.75rem;overflow:hidden;box-shadow:0 .75rem 2rem rgba(15,23,42,.12)}
.select2-container--bootstrap-5 .select2-search__field{border-radius:.6rem}

@media (max-width:767.98px){
  .navbar .container{padding-left:1rem;padding-right:1rem}
  main.container{padding-left:.75rem;padding-right:.75rem}
  .card-body{padding:1rem!important}
  .result-primary,.result-side{min-height:auto;padding:1rem}
  .metric-box{padding:.7rem .6rem;text-align:center}
  .metric-label{font-size:.7rem}
  .metric-value{font-size:.95rem}
  .summary-dose{font-size:1.1rem}
}


/* v11: de-emphasize daily/total volume and prioritize bottle count */
.dispense-summary{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.85rem 1rem;border:1px solid #e5e7eb;border-radius:.9rem;background:#f8fafc}
.dispense-secondary{display:flex;align-items:center;gap:.55rem;flex-wrap:wrap;color:#64748b;font-size:.84rem}
.dispense-secondary strong{color:#475569;font-size:.9rem;font-weight:700}
.summary-sep{color:#cbd5e1}
.dispense-bottles{display:flex;align-items:baseline;gap:.65rem;margin-left:auto}
.dispense-bottles-label{font-size:.84rem;color:#475569;font-weight:600}
.dispense-bottles strong{font-size:1.35rem;color:#0f3b66;font-weight:850;white-space:nowrap}
@media (max-width:575.98px){
  .dispense-summary{align-items:flex-start;flex-direction:column;padding:.8rem .9rem}
  .dispense-bottles{margin-left:0;width:100%;justify-content:space-between;border-top:1px solid #e2e8f0;padding-top:.65rem}
  .dispense-secondary{font-size:.78rem}
  .dispense-secondary strong{font-size:.82rem}
}

/* v12: make administration instructions easier to read at a glance */
.administration-en{font-size:clamp(1.35rem,2.6vw,1.7rem);font-weight:850;line-height:1.2;color:var(--bs-body-color);letter-spacing:-.01em}
.administration-th{font-size:clamp(1.08rem,2.1vw,1.3rem);font-weight:700;line-height:1.45;color:var(--bs-primary)}
@media (max-width:767.98px){
  .administration-en{font-size:1.3rem}
  .administration-th{font-size:1.08rem}
}

/* v14: visual hierarchy — Thai administration text is the key instruction */
.result-mg{font-size:clamp(.95rem,1.8vw,1.1rem);font-weight:650;color:#64748b}
.administration-en{font-size:clamp(.88rem,1.5vw,1rem);font-weight:600;line-height:1.3;color:#64748b;letter-spacing:0}
.administration-th{font-size:clamp(1.45rem,3vw,1.9rem);font-weight:850;line-height:1.35;color:var(--bs-primary);letter-spacing:-.015em}
@media (max-width:767.98px){
  .result-mg{font-size:.95rem}
  .administration-en{font-size:.9rem}
  .administration-th{font-size:1.35rem}
}


/* Step 3 collapsible dispensing panel */
[data-bs-target="#dispensingCollapse"] {
  transition: background-color .2s ease;
}
[data-bs-target="#dispensingCollapse"]:hover {
  background-color: var(--bs-tertiary-bg) !important;
}
[data-bs-target="#dispensingCollapse"] .bi-chevron-down {
  transition: transform .2s ease;
}
[data-bs-target="#dispensingCollapse"][aria-expanded="true"] .bi-chevron-down {
  transform: rotate(180deg);
}


/* V18: bottle count beside usage summary */
.summary-primary-grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:1rem;
  align-items:stretch;
}
.summary-bottle-card{
  min-width:150px;
  padding:0.85rem 1rem;
  border-radius:1rem;
  background:rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.18);
  display:flex;
  flex-direction:column;
  justify-content:center;
  text-align:center;
}
.summary-bottle-label{
  font-size:.82rem;
  opacity:.82;
  margin-bottom:.15rem;
}
.summary-bottle-count{
  font-size:1.7rem;
  font-weight:800;
  line-height:1.1;
  letter-spacing:-.02em;
}
@media (max-width:575.98px){
  .summary-primary-grid{grid-template-columns:1fr;}
  .summary-bottle-card{min-width:0;}
}


/* V22: clearer summary usage + bottle count, while keeping premium dark tone */
.summary-panel{
  background: linear-gradient(135deg, #17324d 0%, #1f3f5f 100%) !important;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 10px 24px rgba(15, 35, 55, .16);
}
.summary-panel .text-body-secondary{
  color: rgba(255,255,255,.72) !important;
}
.summary-dose{
  color: #ffffff !important;
  font-weight: 800 !important;
  text-shadow: 0 1px 1px rgba(0,0,0,.12);
}
.summary-bottle-card{
  background: rgba(255,255,255,.14) !important;
  border: 1px solid rgba(255,255,255,.28) !important;
}
.summary-bottle-label{
  color: rgba(255,255,255,.82) !important;
  font-weight: 600;
}
.summary-bottle-count{
  color: #ffffff !important;
  font-weight: 900 !important;
  text-shadow: 0 1px 1px rgba(0,0,0,.12);
}


/* V38: always-visible Master dose */
.master-dose-visible{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:.5rem;
  padding-top:.75rem;
  border-top:1px solid rgba(0,0,0,.08);
}
.master-dose-label{
  font-size:.82rem;
  color:var(--bs-secondary-color);
  font-weight:600;
}
.master-dose-visible strong{
  color:var(--bs-primary);
  font-size:1rem;
  font-weight:800;
}


/* =========================================================
   V45 Responsive polish
   Desktop / iPad / mobile
   ========================================================= */

html, body{
  max-width:100%;
  overflow-x:hidden;
}

.app-shell{
  max-width:1180px;
}

.card{
  overflow:visible;
}

/* Keep all form controls comfortable for touch */
.form-control,
.form-select,
.input-group-text,
.select2-container--bootstrap-5 .select2-selection{
  min-height:48px;
}

.btn{
  min-height:40px;
}

input[type="number"]{
  font-variant-numeric:tabular-nums;
}

/* Select2 must never overflow its Bootstrap column */
.select2-container{
  width:100% !important;
  max-width:100%;
}

.select2-container--bootstrap-5 .select2-selection--single{
  display:flex;
  align-items:center;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered{
  max-width:calc(100% - 1.75rem);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.select2-container--bootstrap-5 .select2-dropdown{
  max-width:calc(100vw - 1.5rem);
}

.select2-results__option{
  white-space:normal;
  line-height:1.35;
  padding:.65rem .75rem;
}

/* Result hierarchy */
.result-main{
  line-height:1.08;
  overflow-wrap:anywhere;
}

.result-primary,
.result-side{
  height:100%;
}

.administration-th,
.administration-en,
.master-dose-visible strong,
.summary-dose{
  overflow-wrap:anywhere;
}

#freqBadge{
  flex:0 0 auto;
}

/* Collapsible dispensing header is a proper touch target */
[data-bs-target="#dispensingCollapse"]{
  min-height:64px;
}

[data-bs-target="#dispensingCollapse"] h2{
  line-height:1.3;
}

/* Tablet / iPad portrait + landscape */
@media (min-width:768px) and (max-width:1199.98px){
  .app-shell{
    max-width:960px;
    padding-left:1.25rem;
    padding-right:1.25rem;
  }

  main header h1{
    font-size:1.65rem;
  }

  .card-body{
    padding:1.25rem !important;
  }

  .result-primary,
  .result-side{
    padding:1.15rem;
  }

  .result-main{
    font-size:clamp(2rem,5vw,3rem);
  }

  .administration-th{
    font-size:1.45rem;
  }

  .summary-primary-grid{
    grid-template-columns:minmax(0,1fr) 170px;
  }

  .summary-bottle-card{
    min-width:170px;
  }
}

/* Mobile */
@media (max-width:767.98px){
  body{
    font-size:.95rem;
  }

  .navbar .container{
    padding-top:.35rem;
    padding-bottom:.35rem;
  }

  .navbar-brand{
    min-width:0;
    font-size:1rem;
  }

  .navbar-brand > span:last-child{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  .navbar .btn{
    flex:0 0 auto;
    min-height:36px;
    padding:.35rem .65rem !important;
  }

  main.container{
    padding-top:.8rem !important;
    padding-bottom:1.5rem !important;
  }

  main header{
    margin-bottom:.8rem !important;
  }

  main header h1{
    font-size:1.35rem;
    line-height:1.25;
  }

  main header p{
    font-size:.86rem;
  }

  section.card{
    border-radius:1rem !important;
    margin-bottom:.85rem !important;
  }

  .card-body{
    padding:.9rem !important;
  }

  .step-dot{
    flex:0 0 auto;
  }

  .form-label{
    margin-bottom:.35rem;
  }

  .input-group-lg > .form-control,
  .input-group-lg > .input-group-text{
    font-size:1rem;
    padding:.6rem .7rem;
  }

  .select2-container--bootstrap-5 .select2-selection--single{
    min-height:48px;
    padding:.55rem .7rem;
  }

  .select2-container--bootstrap-5 .select2-dropdown{
    max-width:calc(100vw - 1.5rem);
  }

  .select2-search--dropdown{
    padding:.6rem;
  }

  .select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field{
    min-height:44px;
    font-size:16px; /* avoids iOS zoom */
  }

  .result-primary,
  .result-side{
    padding:.95rem;
    border-radius:.9rem;
  }

  .result-main{
    font-size:clamp(2rem,11vw,2.7rem);
  }

  .result-mg{
    margin-top:.35rem !important;
  }

  .master-dose-visible{
    margin-top:.65rem !important;
    padding-top:.6rem;
    gap:.3rem .45rem;
  }

  .master-dose-label{
    width:100%;
  }

  .master-dose-visible strong{
    font-size:.95rem;
  }

  .result-side .d-flex.justify-content-between{
    margin-bottom:.75rem !important;
  }

  .administration-th{
    font-size:1.28rem;
    line-height:1.4;
  }

  .administration-en{
    font-size:.85rem;
    margin-top:.2rem;
  }

  #freqBadge{
    font-size:.9rem !important;
    padding:.45rem .7rem !important;
  }

  [data-bs-target="#dispensingCollapse"]{
    padding:.85rem .95rem !important;
    min-height:58px;
  }

  [data-bs-target="#dispensingCollapse"] h2{
    font-size:.95rem;
  }

  #dispensingCollapse .card-body{
    padding-top:.2rem !important;
  }

  .summary-panel{
    padding:.85rem !important;
  }

  .summary-primary-grid{
    gap:.75rem;
  }

  .summary-dose{
    font-size:1.08rem;
  }

  .summary-bottle-card{
    padding:.7rem .8rem;
  }

  .summary-bottle-count{
    font-size:1.5rem;
  }

  .dispense-summary{
    margin-top:.6rem !important;
  }

  .dispense-secondary{
    width:100%;
    justify-content:flex-start;
  }

  .formula-box{
    font-size:.78rem !important;
    overflow-wrap:anywhere;
  }
}

/* Extra-small phones */
@media (max-width:399.98px){
  .navbar-brand .brand-icon{
    display:none;
  }

  main.container{
    padding-left:.6rem !important;
    padding-right:.6rem !important;
  }

  .card-body{
    padding:.8rem !important;
  }

  .result-main{
    font-size:1.9rem;
  }

  .administration-th{
    font-size:1.18rem;
  }

  [data-bs-target="#dispensingCollapse"] h2{
    font-size:.9rem;
  }

  .summary-bottle-count{
    font-size:1.4rem;
  }
}

/* Landscape phones: use horizontal space without making content tiny */
@media (max-height:520px) and (orientation:landscape) and (max-width:932px){
  main.container{
    padding-top:.6rem !important;
  }

  main header{
    display:none;
  }

  .navbar{
    position:static !important;
  }

  section.card{
    margin-bottom:.65rem !important;
  }
}


/* V48: make Rule/Indication Select2 typography match other main inputs */
#rule + .select2-container .select2-selection--single,
#rule + .select2-container .select2-selection__rendered{
  font-size:1rem !important;
  font-weight:400 !important;
}

#rule + .select2-container .select2-selection--single{
  min-height:48px;
}

#rule + .select2-container .select2-selection__rendered{
  line-height:1.5 !important;
}

/* Match dropdown results to medicine / strength fields */
.select2-container--bootstrap-5 .select2-results__option{
  font-size:1rem;
  font-weight:400;
}

@media (max-width:767.98px){
  #rule + .select2-container .select2-selection--single,
  #rule + .select2-container .select2-selection__rendered,
  .select2-container--bootstrap-5 .select2-results__option{
    font-size:1rem !important;
  }
}


/* V50 top clear button */
#topResetBtn{
  white-space:nowrap;
}
@media (max-width:575.98px){
  #topResetBtn{
    padding:.35rem .65rem !important;
    font-size:.82rem;
  }
  #topResetBtn .bi{
    margin-right:.25rem !important;
  }
}


/* =========================================================
   V53 — Medical Modern color system
   Adds warmth and hierarchy while keeping a clinical look
   ========================================================= */

:root{
  --med-blue:#2563eb;
  --med-blue-soft:#eff6ff;
  --med-teal:#0f766e;
  --med-teal-soft:#ecfdf5;
  --med-mint:#d1fae5;
  --med-amber:#d97706;
  --med-amber-soft:#fff7ed;
  --med-slate:#334155;
  --med-slate-soft:#f8fafc;
  --med-danger-soft:#fef2f2;
}

/* Page atmosphere */
body{
  background:
    radial-gradient(circle at top left, rgba(37,99,235,.05), transparent 34%),
    radial-gradient(circle at top right, rgba(15,118,110,.045), transparent 30%),
    #f8fafc !important;
}

/* Navbar */
.navbar{
  background:rgba(255,255,255,.96) !important;
  backdrop-filter:saturate(140%) blur(8px);
}
.brand-icon{
  background:linear-gradient(135deg,var(--med-blue),#3b82f6);
  color:#fff;
  border-radius:.8rem;
  width:36px;
  height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 .4rem 1rem rgba(37,99,235,.18);
}

/* Main cards */
section.card{
  border:1px solid rgba(148,163,184,.16) !important;
  box-shadow:0 10px 28px rgba(15,23,42,.06) !important;
}

/* Step badges get meaningful distinct accents */
.step-dot{
  background:linear-gradient(135deg,var(--med-blue),#60a5fa) !important;
  color:#fff !important;
  box-shadow:0 .35rem .9rem rgba(37,99,235,.2);
}

section.card:nth-of-type(2) .step-dot{
  background:linear-gradient(135deg,var(--med-teal),#34d399) !important;
  box-shadow:0 .35rem .9rem rgba(15,118,110,.18);
}

section.card:nth-of-type(3) .step-dot{
  background:linear-gradient(135deg,var(--med-amber),#f59e0b) !important;
  box-shadow:0 .35rem .9rem rgba(217,119,6,.18);
}

/* Inputs */
.form-control:focus,
.form-select:focus{
  border-color:#93c5fd;
  box-shadow:0 0 0 .22rem rgba(37,99,235,.10);
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection{
  border-color:#93c5fd !important;
  box-shadow:0 0 0 .22rem rgba(37,99,235,.10) !important;
}

/* Primary result card */
.result-primary{
  background:
    linear-gradient(145deg, rgba(239,246,255,.96), rgba(255,255,255,.98)) !important;
  border:1px solid #bfdbfe !important;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.85);
}
.result-primary::before{
  content:"";
  display:block;
  width:42px;
  height:5px;
  border-radius:999px;
  background:linear-gradient(90deg,var(--med-blue),#60a5fa);
  margin-bottom:.8rem;
}
.result-main{
  color:#1d4ed8 !important;
  text-shadow:0 1px 0 rgba(255,255,255,.9);
}

/* Administration / instruction card */
.result-side{
  background:
    linear-gradient(145deg, rgba(236,253,245,.9), rgba(255,255,255,.98)) !important;
  border:1px solid #a7f3d0 !important;
}
.administration-th{
  color:var(--med-teal) !important;
}
#freqBadge{
  background:#d1fae5 !important;
  color:#065f46 !important;
  border:1px solid #a7f3d0;
}

/* Master dose */
.master-dose-visible{
  border-top-color:rgba(37,99,235,.13) !important;
}
.master-dose-visible strong{
  color:#1d4ed8 !important;
}

/* Step 3 collapse */
[data-bs-target="#dispensingCollapse"]{
  background:linear-gradient(90deg,#fff7ed,#ffffff) !important;
  border-bottom:1px solid #fed7aa;
}
[data-bs-target="#dispensingCollapse"]:hover{
  background:linear-gradient(90deg,#ffedd5,#fff7ed) !important;
}
[data-bs-target="#dispensingCollapse"] .step-dot{
  background:linear-gradient(135deg,var(--med-amber),#f59e0b) !important;
}

/* Selected dose input status */
#selectedMl.is-valid{
  border-color:#34d399;
  background-color:#f0fdf4;
}
#selectedMl.is-invalid{
  border-color:#f87171;
  background-color:#fff7f7;
}

/* Selected range hint */
#selectedRangeHint{
  padding:.55rem .7rem;
  border-radius:.65rem;
  background:#eff6ff;
  border:1px solid #dbeafe;
}

/* Summary panel */
.summary-panel{
  background:
    radial-gradient(circle at 12% 15%, rgba(52,211,153,.14), transparent 30%),
    linear-gradient(135deg,#153550 0%,#214b63 55%,#1f5c5a 100%) !important;
  box-shadow:0 14px 30px rgba(15,35,55,.18) !important;
}
.summary-bottle-card{
  background:rgba(255,255,255,.15) !important;
  border-color:rgba(255,255,255,.3) !important;
}
.summary-bottle-count{
  color:#ecfdf5 !important;
}

/* Secondary dispense totals */
.dispense-summary{
  background:linear-gradient(90deg,#f8fafc,#f1f5f9) !important;
  border-color:#dbe3ec !important;
}

/* Formula and note boxes */
.formula-box{
  background:#f8fafc;
  border-radius:.75rem;
  padding:.8rem;
  border:1px dashed #cbd5e1;
}
#noteBox{
  border-left:4px solid #f59e0b;
  background:#fffaf0;
}

/* Buttons */
.btn-primary{
  background:linear-gradient(135deg,var(--med-blue),#3b82f6);
  border-color:var(--med-blue);
  box-shadow:0 .35rem .8rem rgba(37,99,235,.16);
}
.btn-primary:hover{
  background:linear-gradient(135deg,#1d4ed8,#2563eb);
}
#topResetBtn{
  background:#fff;
  border-color:#fecaca;
}
#topResetBtn:hover{
  background:var(--med-danger-soft);
}

/* Responsive color polish */
@media (max-width:767.98px){
  .result-primary::before{
    width:36px;
    height:4px;
  }

  #selectedRangeHint{
    padding:.5rem .6rem;
  }

  .summary-panel{
    border-radius:.9rem;
  }
}


/* =========================================================
   V54 — Stronger top actions + readable hover states
   ========================================================= */

/* Top action group should look intentional */
.navbar .d-flex.align-items-center.gap-2{
  gap:.55rem !important;
}

/* Clear button: strong red accent */
#topResetBtn{
  background:linear-gradient(135deg,#fff1f2,#ffe4e6) !important;
  color:#b91c1c !important;
  border:1px solid #fda4af !important;
  font-weight:800 !important;
  box-shadow:0 .35rem .85rem rgba(185,28,28,.10);
}

#topResetBtn .bi{
  color:#b91c1c !important;
}

#topResetBtn:hover,
#topResetBtn:focus,
#topResetBtn:active{
  background:linear-gradient(135deg,#dc2626,#ef4444) !important;
  color:#ffffff !important;
  border-color:#dc2626 !important;
  box-shadow:0 .45rem 1rem rgba(220,38,38,.22) !important;
}

#topResetBtn:hover .bi,
#topResetBtn:focus .bi,
#topResetBtn:active .bi{
  color:#ffffff !important;
}

/* Master button: distinct navy/teal action */
.navbar a[href="master.php"]{
  background:linear-gradient(135deg,#0f3b66,#155e75) !important;
  color:#ffffff !important;
  border:1px solid #0f3b66 !important;
  font-weight:800 !important;
  box-shadow:0 .35rem .85rem rgba(15,59,102,.16);
}

.navbar a[href="master.php"] .bi{
  color:#ffffff !important;
}

.navbar a[href="master.php"]:hover,
.navbar a[href="master.php"]:focus,
.navbar a[href="master.php"]:active{
  background:linear-gradient(135deg,#0b2f52,#0f4c5c) !important;
  color:#ffffff !important;
  border-color:#0b2f52 !important;
  box-shadow:0 .45rem 1rem rgba(15,59,102,.24) !important;
}

.navbar a[href="master.php"]:hover .bi,
.navbar a[href="master.php"]:focus .bi,
.navbar a[href="master.php"]:active .bi{
  color:#ffffff !important;
}

/* Keep Bootstrap from washing button text out on hover */
.navbar .btn{
  transition:
    background-color .18s ease,
    color .18s ease,
    border-color .18s ease,
    box-shadow .18s ease,
    transform .18s ease;
}

.navbar .btn:hover{
  transform:translateY(-1px);
}

/* Mobile sizing: still prominent without crowding navbar */
@media (max-width:575.98px){
  #topResetBtn,
  .navbar a[href="master.php"]{
    min-height:38px;
    padding:.4rem .72rem !important;
    font-size:.82rem;
  }
}


/* V55 — Vertically center Master button icon + text */
.navbar a[href="master.php"]{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  line-height:1 !important;
}

.navbar a[href="master.php"] .bi{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  line-height:1 !important;
  vertical-align:middle !important;
}

/* V66 */
#selectedDoseEdgeWarning{border-color:#f59e0b;background:#fff7ed;color:#9a3412}
.master-test-box{padding:1rem;border-radius:.9rem;background:linear-gradient(135deg,#f8fafc,#eff6ff);border:1px solid #dbeafe}
.master-test-result{min-height:48px;border-radius:.75rem;border:1px solid #cbd5e1;background:#fff;display:flex;flex-direction:column;justify-content:center;padding:.6rem .8rem;color:#1e3a5f}
.master-test-result strong{font-size:1.1rem;color:#1d4ed8}
@media(max-width:767.98px){.master-test-box{padding:.8rem}}


/* ===== V100: Pediatric input layout ===== */
.dose-input-grid {
  display: grid;
  grid-template-columns: minmax(190px, 0.9fr) minmax(320px, 1.55fr) minmax(250px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.dose-input-grid.has-age {
  grid-template-columns:
    minmax(170px, 0.85fr)
    minmax(210px, 0.95fr)
    minmax(280px, 1.35fr)
    minmax(220px, 1fr);
}

.dose-field {
  min-width: 0;
}

.dose-field .form-label {
  margin-bottom: .55rem;
}

.dose-field .input-group,
.dose-field .select2-container {
  width: 100% !important;
}

.dose-field .form-text {
  min-height: 1.3rem;
  margin-top: .5rem;
  line-height: 1.35;
}

.age-input-group .age-unit-select {
  flex: 0 0 105px;
  max-width: 105px;
}

.dose-field-medicine .select2-selection,
.dose-field-strength .select2-selection {
  min-height: 48px;
}

.dose-field-medicine .select2-selection__rendered,
.dose-field-strength .select2-selection__rendered {
  line-height: 46px !important;
}

.dose-field-medicine .select2-selection__arrow,
.dose-field-strength .select2-selection__arrow {
  height: 46px !important;
}

@media (max-width: 1199.98px) {
  .dose-input-grid,
  .dose-input-grid.has-age {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dose-field-medicine,
  .dose-field-strength {
    grid-column: span 1;
  }
}

@media (max-width: 767.98px) {
  .dose-input-grid,
  .dose-input-grid.has-age {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .dose-field .form-text {
    min-height: 0;
  }

  .age-input-group .age-unit-select {
    flex-basis: 98px;
    max-width: 98px;
  }
}


/* V101: Desloratadine uses age instead of weight */
.dose-input-grid.has-age {
  grid-template-columns: minmax(210px, 0.95fr) minmax(320px, 1.45fr) minmax(250px, 1.05fr);
}

@media (max-width: 1199.98px) {
  .dose-input-grid.has-age {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dose-input-grid.has-age .dose-field-strength {
    grid-column: span 1;
  }
}

@media (max-width: 767.98px) {
  .dose-input-grid.has-age {
    grid-template-columns: 1fr;
  }
}


/* V102: Fix age unit dropdown width */
.age-input-group .age-unit-select {
  flex: 0 0 118px;
  width: 118px;
  min-width: 118px;
  max-width: 118px;
  white-space: nowrap;
  padding-left: .75rem;
  padding-right: 2rem;
}

@media (max-width: 767.98px) {
  .age-input-group .age-unit-select {
    flex-basis: 112px;
    width: 112px;
    min-width: 112px;
    max-width: 112px;
  }
}


/* V104: tidy indication / regimen field */
.rule-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--bs-border-color);
}

.rule-field {
  width: min(100%, 760px);
  margin-left: 0;
  margin-right: auto;
}

.rule-field .form-label {
  margin-bottom: .55rem;
}

.rule-field .select2-container {
  width: 100% !important;
}

.rule-field .select2-selection {
  min-height: 48px;
}

.rule-field .select2-selection__rendered {
  line-height: 46px !important;
  padding-left: .9rem !important;
  padding-right: 2.5rem !important;
}

.rule-field .select2-selection__arrow {
  height: 46px !important;
}

.rule-field .form-text {
  margin-top: .5rem;
  min-height: 1.3rem;
  line-height: 1.35;
}

@media (max-width: 1199.98px) {
  .rule-field {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 767.98px) {
  .rule-section {
    margin-top: 14px;
    padding-top: 14px;
  }

  .rule-field .form-text {
    min-height: 0;
  }
}
