/* UI cleanup v2.20.6 */
.patient-lab-head {
  align-items: center;
  gap: 12px;
}
.patient-lab-head > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}
.patient-lab-range {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.patient-lab-range select {
  min-width: 128px;
}
.patient-tab-panel > .panel-head {
  margin-bottom: 0;
}

/* Keep both profile columns starting on the same top baseline. */
#profile.active .patient-profile-layout {
  align-items: start;
}
#profile.active .patient-profile-sidebar,
#profile.active .patient-profile-workspace {
  align-self: start;
}
#profile.active .patient-profile-sidebar {
  position: static;
  top: auto;
}

/* Vital sub-tabs: one metric per chart. */
.patient-vital-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.patient-vital-head > div:first-child {
  flex: 0 0 auto;
}
.patient-vital-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-left: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.patient-vital-tabs button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.patient-vital-tabs button.active,
.patient-vital-tabs button[aria-selected="true"] {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
  box-shadow: 0 5px 14px rgba(15,118,110,.14);
}
.vital-chart-panel {
  padding-top: 12px;
}
#patientVitalHistory .profile-table-wrap {
  max-height: 300px;
}

@media (max-width: 800px) {
  .patient-vital-head {
    align-items: stretch;
    flex-direction: column;
  }
  .patient-vital-tabs {
    width: 100%;
    margin-left: 0;
  }
}
@media (max-width: 600px) {
  .patient-lab-head {
    align-items: stretch;
  }
  .patient-lab-range {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }
  .patient-lab-range select {
    width: auto;
    min-width: 140px;
  }
}
/* Profile overview: latest important follow-up values. */
#profile.active #vitalGrid .overview-key-value {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 104px;
  align-content: start;
}
#profile.active #vitalGrid .overview-key-value.warn {
  border-color: #f59e0b;
  background: #fffbeb;
}
#profile.active #vitalGrid .overview-key-value.danger {
  border-color: #ef4444;
  background: #fff1f2;
}
.overview-key-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.overview-key-status {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}
.overview-key-value.warn .overview-key-status { color: #b45309; }
.overview-key-value.danger .overview-key-status { color: #b91c1c; }
.overview-key-value strong {
  margin-top: 1px;
  font-size: 20px;
}
.overview-key-value strong small {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.overview-key-date {
  margin-top: auto;
  padding-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Annual Lab tracking */
.lab-annual-scope-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
  margin-top: 14px;
}
.lab-annual-scope-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 14px;
}
.lab-annual-scope-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.lab-annual-scope-head strong {
  font-size: 16px;
}
.lab-annual-scope-head span {
  color: var(--muted);
  font-size: 13px;
}
.lab-annual-scope-actions {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
}
.lab-annual-scope-actions button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ecfdf5;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.lab-annual-scope-actions button.missing {
  background: #fff1f2;
  border-color: #fecdd3;
}
.lab-annual-scope-actions span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.lab-annual-scope-actions b {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  color: var(--text);
}
.annual-lab-status,
.annual-lab-missing {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.annual-lab-status.tested {
  background: #dcfce7;
  color: #15803d;
}
.annual-lab-status.missing,
.annual-lab-missing {
  background: #fee2e2;
  color: #b91c1c;
}
@media (max-width: 800px) {
  .lab-annual-scope-grid { grid-template-columns: 1fr; }
}

/* Click-through summary cards */
.module-summary-card.clickable {
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.module-summary-card.clickable:hover,
.module-summary-card.clickable:focus-visible {
  transform: translateY(-1px);
  border-color: #0f766e;
  box-shadow: 0 8px 18px rgba(15,118,110,.12);
  outline: none;
}
.module-summary-card.clickable::after {
  content: "กดดูทะเบียน";
  margin-top: 4px;
  color: #0f766e;
  font-size: 11px;
  font-weight: 800;
}

/* Settings content tabs */
.settings-tablist {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 6px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.settings-tablist button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}
.settings-tablist button.active,
.settings-tablist button[aria-selected="true"] {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
}
.settings-tab-panel[hidden] {
  display: none !important;
}
#settings .settings-grid {
  align-items: start;
}
