* { box-sizing: border-box; margin: 0; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f8f6;
  color: #1a202c;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, #0e6a50 0%, #0d5c46 100%);
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
header h1 { font-size: 1.4rem; display: flex; align-items: center; gap: .5rem; }
.header-left { display: flex; align-items: baseline; gap: 1rem; }
.back-qb {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  color: #bfe3d4; border: 1px solid rgba(255,255,255,.35);
  font-size: .72rem; text-decoration: none; white-space: nowrap; flex-shrink: 0;
}
.back-qb:hover { color: #fff; border-color: #fff; }
.logo-tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; border: 2px solid #0d5c46;
  font-size: 17px; line-height: 1;
  box-shadow: 0 1px 3px rgba(13,92,70,.25);
}
#user-badge { display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
.header-right { display: flex; gap: 1rem; align-items: center; }
#guest-nav { display: flex; gap: 1rem; align-items: center; }
#guest-nav .small, #lang-toggle {
  background: none;
  border: none;
  color: #e6f4ef;
  font-size: .95rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: .3rem .4rem;
  border-radius: 4px;
}
#guest-nav .small:hover, #lang-toggle:hover {
  color: #fff;
  background: rgba(255,255,255,.15);
  text-decoration: none;
}
#guest-nav .small:active, #lang-toggle:active {
  background: rgba(255,255,255,.35);
}
.menu-wrap { position: relative; }
.drop-menu {
  position: absolute;
  right: 0;
  top: calc(100% + .4rem);
  min-width: 190px;
  padding: .4rem;
  border: 1px solid #d7e4dd;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  overflow: hidden;
  z-index: 20;
}
.drop-menu a {
  display: block;
  padding: .5rem .8rem;
  color: #1a202c;
  text-decoration: none;
  font-size: .88rem;
  border-radius: 6px;
  white-space: nowrap;
}
.drop-menu a:hover { background: #e6f4ef; }
.fp-tabs { display: flex; gap: .4rem; margin-bottom: .8rem; border-bottom: 2px solid #e2e8f0; }
.fp-tab {
  flex: 1; padding: .45rem; border: none; border-bottom: 3px solid transparent;
  border-radius: 0; background: none; color: #4a5568; font-size: .85rem; cursor: pointer;
}
.fp-tab:hover { background: none; color: #0d5c46; }
.fp-tab.on { color: #0d5c46; border-bottom-color: #0d5c46; font-weight: 600; }

/* bilingual date-picker popup (ethcal.js) */
.calpop {
  position: fixed; z-index: 300; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 300px; max-width: calc(100vw - 24px); padding: 12px;
  background: #fff; border: 1px solid #d7e5de; border-radius: 14px;
  box-shadow: 0 16px 48px rgba(9, 45, 36, .30); font-size: 13px; color: #16332a;
}
@media (max-width: 640px) {
  .calpop { padding: 14px; }
  .calpop .cp-day { padding: 10px 0; font-size: 15px; }
  .calpop .cp-wd { font-size: 11px; padding: 4px 0; }
  .calpop select.cp-month, .calpop select.cp-year { font-size: 14px; padding: 5px 4px; }
  .calpop .cp-toggle label { font-size: 14px; padding: 7px 8px; }
}
.cp-toggle { display: flex; gap: 10px; margin-bottom: 8px; }
.cp-toggle label {
  display: flex; align-items: center; gap: 4px; padding: 4px 8px;
  border: 1px solid #d7e5de; border-radius: 8px; background: #fff;
  color: #3a6a5c; font-size: 12px; cursor: pointer; flex: 1; justify-content: center;
}
.cp-toggle label.on { border-color: #0d5c46; color: #0d5c46; font-weight: 600; }
.cp-toggle input { accent-color: #0d5c46; margin: 0; }
.cp-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
select.cp-month { flex: 1; min-width: 0; }
select.cp-year { width: 62px; flex-shrink: 0; }
select.cp-month, select.cp-year {
  border: 1px solid #c4d8d0; border-radius: 6px; font-size: 12px;
  padding: 3px 2px; color: #16332a; background: #fff; font-weight: 600;
}
.cp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; }
.cp-wd { font-size: 10px; color: #7a9a90; padding: 2px 0; }
.cp-day {
  padding: 4px 0; border: 0; background: none; border-radius: 6px;
  font-size: 12px; cursor: pointer; color: #16332a;
}
.cp-day:hover { background: #d9efe7; }
.cp-day.today { outline: 1px solid #0d5c46; }
.cp-day.sel { background: #0d5c46; color: #fff; }
.hero { text-align: center; padding: 4rem 1rem; animation: fadeUp .6s ease-out both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.hero h2 {
  font-size: 2.1rem;
  letter-spacing: -.02em;
  color: #134e3f;
}
.hero h2 .accent {
  background: linear-gradient(120deg, #0d5c46 20%, #1aa478 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.hero-roles { color: #8a9b93; font-size: .8rem; letter-spacing: .06em; margin: -.3rem 0 .5rem; }
.tagline1 { color: #12805f; font-weight: 600; font-size: 1.05rem; margin-bottom: .15rem; }
.tagline2 { font-size: .95rem; }
.hero-cta { line-height: 1.9; }
#scan-video { width: 100%; border-radius: 8px; background: #111; }
.pat-id-card { padding: .7rem .9rem; }
.pat-id-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: .5rem; background: #f0f9f5; color: #0d5c46; border: 1.5px solid #0d5c46; border-radius: 8px; padding: .6rem 1rem; font-weight: 600; font-size: .95rem; cursor: pointer; }
.pat-id-toggle:hover { background: #e2f3ec; }
.pat-id-chev { font-size: .8rem; }
.patid-card { text-align: center; }
.patid-card .sub-box { font-size: .7rem; word-break: break-all; }
#pat-qr { margin-top: .6rem; border: 1px solid #e5e5e5; border-radius: 6px; }
.stats-title { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: #0d5c46; font-weight: 600; text-align: center; margin-bottom: .4rem; }
.stats-row { display: flex; gap: 1.8rem; justify-content: center; flex-wrap: wrap; margin: .4rem 0 .8rem; }
.footer-line { border: 0; border-top: 1px solid #d6e6df; margin: .5rem 0; }
.stat { text-align: center; }
.stat-n { display: block; font-size: 1.5rem; font-weight: 800; color: #0d5c46; }
.stat-n.c-pat { color: #2b6cb0; }
.stat-n.c-doc { color: #12805f; }
.stat-n.c-ph { color: #b7791f; }
.stat-n.c-lab { color: #6b46c1; }
.stat-l { font-size: .8rem; color: #666; }
.site-footer {
  margin-top: 4rem;
  padding: 1.2rem;
  border-top: 3px solid #0d5c46;
  background: #ecf5f1;
  border-radius: 0 0 10px 10px;
  font-size: .82rem;
  display: grid;
  gap: .2rem;
}
.site-footer a { color: #12805f; }
.hp { position: absolute; left: -9999px; height: 0; opacity: 0; }
textarea {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid #c9d8d2;
  border-radius: 8px;
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
}
textarea:focus { outline: none; border-color: #12805f; box-shadow: 0 0 0 3px #d8efe6; }
.hero h2 { font-size: 1.8rem; margin-bottom: .6rem; }
.hero-cta { margin-top: 1.5rem; font-size: .95rem; }
.hero-cta a {
  color: #0d5c46;
  padding: .35rem .5rem;
  border-radius: 6px;
  transition: background .15s;
}
.hero-cta a:hover { background: #e6f4ef; text-decoration: none; }
.cta-row { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
.cta-row button { padding: .75rem 1.4rem; font-size: 1rem; transition: transform .15s, box-shadow .15s; }
@media (max-width: 600px) { .cta-row button { padding: .85rem 1.3rem; font-size: 1.05rem; } }
.cta-row button:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(13,92,70,.18); }
.cta-row .ghost-btn { background: #fff; color: #0d5c46; border: 1.5px solid #0d5c46; }
.cta-row .ghost-btn:hover { background: #f0f9f5; }
.small-links { margin-top: .3rem; font-size: .9rem; display: flex; gap: 1.2rem; justify-content: center; }
.how-link { display: inline-block; transition: transform .15s; color: var(--green, #0d5c46); font-weight: 600; }
.how-link:hover { transform: translateX(3px); }
.hero .demo-users { max-width: 420px; margin: 3rem auto 0; }
.flow-wrap { margin-top: 2.5rem; }
.flow { width: 100%; max-width: 560px; height: auto; }
.flow .node circle { fill: #e6f4ef; stroke: #12805f; stroke-width: 2; }
/* Role colors — node, badge and inbound path share a hue */
.flow .node.n-pat circle { fill: #e8f0fa; stroke: #2b6cb0; }
.flow .node.n-doc circle { fill: #e6f4ef; stroke: #12805f; }
.flow .node.n-ph  circle { fill: #fdf2df; stroke: #b7791f; }
.flow .node.n-lab circle { fill: #efe9fb; stroke: #6b46c1; }
.flow .node.n-pat:hover circle { fill: #d4e4f5; }
.flow .node.n-doc:hover circle { fill: #d1ebe1; }
.flow .node.n-ph:hover  circle { fill: #f9e6c4; }
.flow .node.n-lab:hover circle { fill: #e2d8f7; }
#fp-pat-doc { stroke: rgba(18,128,95,.4); }
#fp-doc-lab { stroke: rgba(107,70,193,.4); }
#fp-doc-ph  { stroke: rgba(183,121,31,.4); }
#fp-lab-doc { stroke: rgba(18,128,95,.4); }
#fp-ph-pat  { stroke: rgba(43,108,176,.4); }
.n-pat .badge circle { fill: #e8f0fa; stroke: #2b6cb0; }
.n-pat .badge text { fill: #1e4e82; }
.n-doc .badge circle { fill: #e6f4ef; stroke: #12805f; }
.n-doc .badge text { fill: #0d5c44; }
.n-ph .badge circle { fill: #fdf2df; stroke: #b7791f; }
.n-ph .badge text { fill: #86550f; }
.n-lab .badge circle { fill: #efe9fb; stroke: #6b46c1; }
.n-lab .badge text { fill: #4d2f96; }
.flow .icon { font-size: 24px; text-anchor: middle; }
.flow .lbl { font-size: 14px; text-anchor: middle; fill: #134e3f; font-weight: 700; }


.flow-word {
  font-size: 16px;
  font-weight: bold;
  fill: #12805f;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #f5f8f6;
  stroke-width: 5px;
}
.flow .badge { display: none; }  /* SVG count bubbles only — status pills use .badge too */
.badge circle { fill: #e6f4ef; stroke: #12805f; stroke-width: 2; }
.badge text { fill: #134e3f; font-size: 13px; font-weight: bold; text-anchor: middle; }
.flow .node { cursor: pointer; }
.flow .node:hover circle { fill: #d1ebe1; }
@media (max-width: 560px) {
  .flow { max-width: 100%; }

}
[hidden] { display: none !important; }
#logout-btn { background: rgba(255,255,255,.2); color: #fff; border: 0; padding: .4rem .8rem; border-radius: 6px; cursor: pointer; }
main { width: 100%; box-sizing: border-box; max-width: 720px; margin: 1.5rem auto; padding: 0 1rem; display: grid; gap: 1rem; flex: 1; }
.copyright-bar { border-top: 1px solid #d6e6df; text-align: center; padding: .8rem 1rem; font-size: .8rem; }
.copyright-bar .muted { color: #6b7a73; }
#user-info { display: inline-block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

@media (max-width: 560px) {
  header { flex-wrap: wrap; padding: .75rem 1rem; row-gap: .4rem; }
  header h1 { font-size: 1.15rem; }
  .header-right { flex-wrap: wrap; justify-content: flex-end; row-gap: .3rem; }
  #guest-nav { gap: .7rem; }
  #guest-nav .small, #lang-toggle { font-size: .85rem; padding: .2rem .3rem; }
  #user-badge { flex-wrap: wrap; gap: .4rem; font-size: .8rem; }
  #user-info {
    display: inline-block;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }
  #profile-menu { left: .5rem; right: .5rem; min-width: 0; }
  .hero { padding: 2.5rem .5rem; }
  .hero h2 { font-size: 1.4rem; }
  .modal-card { max-width: 95vw; }
  .modal-card.flow-card { max-width: 98vw; padding: .8rem .6rem; }
}
.card {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(13,92,70,.07);
  border: 1px solid #e6ede9;
}
.card h2 { font-size: 1.1rem; margin-bottom: .75rem; color: #134e3f; }
input, select {
  display: block;
  width: 100%;
  padding: .6rem;
  margin-bottom: .6rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: .95rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #0d5c46;
  box-shadow: 0 0 0 3px #e6f4ef;
}
button {
  background: #12805f;
  color: #fff;
  border: 0;
  padding: .65rem 1.2rem;
  border-radius: 6px;
  font-size: .95rem;
  cursor: pointer;
}
button:not([class]):hover, button.small:hover { background: #0f6b4e; }
button.small { padding: .35rem .8rem; font-size: .85rem; }
.error { color: #c53030; margin-top: .5rem; font-size: .9rem; }
.ok { color: #0d5c46; margin-top: .5rem; font-size: .9rem; }
.muted { color: #718096; }
.small-text { font-size: .8rem; margin-top: .5rem; }
.sub-box {
  display: inline-block;
  background: #edf2f7;
  padding: .5rem .75rem;
  border-radius: 6px;
  font-size: .85rem;
  word-break: break-all;
}
.med-row, .result-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr .6fr 1.5fr auto;
  gap: .5rem;
  margin-bottom: .5rem;
  align-items: center;
}
.med-row input { margin-bottom: 0; }
.lab-test-row { display: flex; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.lab-test-row input { margin-bottom: 0; flex: 1; }
.row-del {
  background: #e2e8f0;
  color: #718096;
  padding: .35rem .6rem;
  font-size: .8rem;
  line-height: 1;
}
.row-del:hover { background: #fed7d7; color: #9b2c2c; }
button.danger { background: #fff; color: #9b2c2c; border: 1px solid #feb2b2; }
button.danger:hover { background: #9b2c2c; color: #fff; }
.stock-add { display: flex; flex-wrap: wrap; gap: .5rem; }
.stock-add input, .stock-add select { margin-bottom: 0; }
.stock-add #stock-name { flex: 2 1 180px; }
.stock-add #stock-status { flex: 0 0 auto; width: auto; }
.stock-add #stock-price { flex: 1 1 90px; }
.stock-set { width: auto; margin-bottom: 0; padding: .2rem .4rem; }
.result-row { grid-template-columns: 1.2fr 1.2fr 1fr .8fr; }
.result-row input, .result-row select { margin-bottom: 0; }
.item {
  border-top: 1px solid #e2e8f0;
  padding: .75rem 0;
}
.item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.item ul { padding-left: 1.2rem; }
.badge {
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 999px;
}
.badge.pending, .badge.ordered { background: #feebc8; color: #975a16; }
.badge.dispensed, .badge.completed { background: #c6f6d5; color: #276749; }
.badge.cancelled { background: #fed7d7; color: #9b2c2c; }
.demo-users { margin-top: 1rem; font-size: .85rem; color: #718096; }
.code { font-family: ui-monospace, monospace; font-weight: 700; color: #0d5c46; letter-spacing: .05em; }
h3 { font-size: .95rem; margin: .9rem 0 .4rem; color: #2d3748; }

/* Tabs */
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; border-bottom: 2px solid #e2e8f0; }
.tab {
  background: none;
  color: #4a5568;
  border: none;
  border-bottom: 3px solid transparent;
  padding: .6rem 1.1rem;
  font-size: .9rem;
  border-radius: 0;
}
.tab:hover, .tab:active, .tab:focus { background: none; color: #0d5c46; border-bottom-color: #8fc7b2; outline: none; }
.tab.active { color: #0d5c46; border-bottom-color: #0d5c46; font-weight: 600; }
.tab-radio { accent-color: #0d5c46; margin-right: .4rem; vertical-align: middle; pointer-events: none; }

/* Nested sub-tabs (doctor view) */
.subtabs {
  margin-top: .75rem;
  margin-bottom: 0;
  padding-bottom: .7rem;
  border-bottom: 1px solid #e2e8f0;
}
.subtabs .tab { padding: .35rem .9rem; font-size: .82rem; }
.subpanel { margin-top: 1rem; }

/* Secondary actions shown as links instead of filled buttons */
.link-btn {
  background: none;
  border: none;
  color: #0d5c46;
  font-size: .85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: .3rem .45rem;
  border-radius: 4px;
}
.link-btn:hover { background: #e6f4ef; text-decoration: none; }
.link-btn:active { background: #d1ebe1; }

input.input-error { border-color: #c53030 !important; box-shadow: 0 0 0 1px #c53030; }

.patient-search { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap; }
.patient-search .small-text { margin-right: .2rem; }
.patient-search input { flex: 1; }
.patient-search input[type="date"] { flex: 0 0 auto; width: 150px; }

/* Profile dropdown */
.profile-wrap { position: relative; display: inline-block; }
#profile-menu {
  color: #1a202c;
  position: absolute;
  right: .5rem;
  top: calc(100% + .4rem);
  z-index: 20;
  min-width: 240px;
  max-width: calc(100vw - 1rem);
  text-align: left;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  padding: 1rem 1.1rem;
  overflow-wrap: break-word;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}
#profile-menu p { margin: .15rem 0; font-size: .9rem; }
#profile-menu input { margin-top: .4rem; }
#profile-menu input:disabled {
  background: transparent;
  border-color: transparent;
  border-bottom: 1px solid #e2e8f0;
  color: #1a202c;
  padding-left: 0;
  opacity: 1;
}
#pe-transfer-btn { width: 100%; text-align: left; }
#pe-delete {
  margin-top: 1rem;
  padding-top: .9rem;
  border-top: 1px solid #e2e8f0;
  width: 100%;
  text-align: left;
  background: none;
  color: #c53030;
  font-size: .85rem;
}
#pe-delete:hover { background: #fff5f5; }

/* Search modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-card { width: 100%; max-width: 440px; margin: 0; position: relative; }
.modal-card.flow-card { max-width: 760px; }
.modal-x {
  position: absolute;
  top: .7rem;
  right: .7rem;
  width: auto;
  padding: .15rem .55rem;
  margin: 0;
  background: none;
  border: none;
  color: #e53e3e;
  font-size: 1.15rem;
  font-weight: bold;
  cursor: pointer;
  border-radius: 6px;
}
.modal-x:hover { background: #fff5f5; }
.modal-card input { margin-top: .4rem; }
.modal-actions { display: flex; gap: .4rem; margin-top: .6rem; }
#md-results, #mid-results { margin-top: .6rem; }

/* Records type filter */
.record-filter {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .75rem;
  font-size: .9rem;
}
.record-filter label { display: flex; align-items: center; gap: .35rem; }
.record-filter input[type="checkbox"] { width: auto; margin: 0; }

/* Collapsible record sections */
details > summary {
  cursor: pointer;
  font-weight: 600;
  padding: .5rem .25rem;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: .6rem;
}
details[open] > summary { border-bottom-color: #0d5c46; }


.auth-links { margin-top: .8rem; font-size: .88rem; }
.auth-links a {
  color: #0d5c46;
  display: block;
  margin-top: .4rem;
  padding: .35rem .5rem;
  border-radius: 6px;
  transition: background .15s;
}
.auth-links a:hover { background: #e6f4ef; text-decoration: none; }
.org-link { margin-top: 1.2rem; font-size: .8rem; text-align: center; }
.org-link a { color: #718096; }
.date-wrap { display: flex; gap: .4rem; align-items: stretch; margin-bottom: .6rem; }
.date-wrap input { flex: 1; margin-bottom: 0; }
.cal-btn {
  padding: 0 .6rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background: #f7fafc;
  cursor: pointer;
  font-size: 1rem;
}
textarea {
  width: 100%;
  padding: .6rem .75rem;
  margin-bottom: .6rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: .95rem;
  font-family: inherit;
  min-height: 3.2rem;
  resize: vertical;
}

/* family switcher (patient view) + doctor family chips */
.fam-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .55rem; flex-wrap: wrap; }
.fam-row select {
  flex: 1; min-width: 140px; padding: .4rem .5rem; border: 1px solid #c8ddd4;
  border-radius: 8px; background: #fff; color: #16332a; font-size: .9rem;
}
.fam-chips { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 .5rem; }
.fam-chip {
  border: 1.5px solid #0d5c46; background: #fff; color: #0d5c46; border-radius: 999px;
  padding: .3rem .8rem; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.fam-chip:hover { background: #f0f9f5; }
.fam-chip.on { background: #0d5c46; color: #fff; }
#fam-list .item { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; flex-wrap: wrap; }
#fam-list { border-bottom: 2px solid #d7e4dd; margin-bottom: .8rem; padding-bottom: .4rem; }
.fam-item { border-bottom: 1.5px solid #d7e4dd; }
.fam-item:last-child { border-bottom: none; }
.fam-item-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; background: none; color: #16332a; border: none; border-radius: 0;
  padding: .55rem .1rem; font-size: .95rem; text-align: left;
}
.fam-item-head:hover, .fam-item-head:active, .fam-item-head:focus {
  background: none; color: #0d5c46; outline: none;
}
.fam-item-chev { color: #718096; font-size: .85rem; }
.fam-item-body {
  display: flex; gap: .4rem; flex-wrap: wrap; align-items: center;
  padding: 0 .1rem .6rem;
}

/* transfer rows */
.fam-tr-row { display: flex; gap: .4rem; width: 100%; margin-top: .3rem; }
.fam-tr-row input { flex: 1; }
#pe-transfer-row { display: flex; gap: .4rem; margin-top: .4rem; }
#pe-transfer-row input { flex: 1; }
#transfer-inbox { border-left: 4px solid #0d5c46; }

/* record status badges */
.badge { border-radius: 999px; padding: .1rem .55rem; font-size: .72rem; font-weight: 700; letter-spacing: .03em; }
.badge.pending, .badge.ordered { background: #fdf3e0; color: #92610a; border: 1px solid #ecc97e; }
.badge.dispensed, .badge.completed { background: #e7f5ee; color: #0d5c46; border: 1px solid #9ed3bd; }
.badge.cancelled { background: #f1f1f1; color: #8a8a8a; border: 1px solid #d5d5d5; text-decoration: line-through; }

.modal-btns { display: flex; gap: .5rem; margin-top: .6rem; }
#pe-edit { width: 100%; text-align: left; margin-top: .8rem; }
#profile-menu { min-width: 300px; padding: .9rem 1rem; }
#profile-details p { margin: .3rem 0; font-size: .88rem; overflow-wrap: anywhere; }
.hero-newuser { margin: 1.2rem 0 .3rem; font-size: .85rem; }

.demo-table { margin-top: .5rem; border-collapse: collapse; width: 100%; font-size: .82rem; }
.demo-table td { padding: .25rem .4rem; border-top: 1px solid #eef2f0; vertical-align: top; text-align: left; }
.demo-table td:first-child { white-space: nowrap; color: #4a5568; font-weight: 600; }
.demo-table code { font-size: .78rem; }

/* ---------- appointments ---------- */
.appt-item { border-left: 4px solid transparent; }
.appt-upcoming { border-left-color: #2e9e5b; background: #f2fbf5; }
.appt-past { opacity: .75; }
.appt-cancelled { opacity: .6; }
.appt-cancelled strong, .appt-cancelled .muted { text-decoration: line-through; }
.appt-sub { font-size: .95rem; margin: 1rem 0 .4rem; color: #444; }
.badge-cancelled { background: #eee; color: #666; }
.badge-done { background: #e8e8e8; color: #555; }
.chip:hover { background: #f0f9f5; border-color: #0d5c46; }
.chip { border: 1px solid #9fc4b4; background: #fff; color: #0d5c46; border-radius: 999px; padding: .25rem .8rem; cursor: pointer; font-size: .85rem; }
.chip.active { background: #0d5c46; color: #fff; border-color: #0d5c46; }
.dir-item a { color: #0d5c46; font-weight: 600; }
.bk-slots { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.bk-slot.on { background: #0d5c46; color: #fff; border-color: #0d5c46; }
#bk-dt { display: block; width: 100%; margin: .4rem 0; padding: .5rem; box-sizing: border-box; }
.feedback-item { border-left: 4px solid #b26a00; background: #fff8ec; }
.fb-actions { display: flex; gap: .4rem; margin-top: .4rem; }
.ghost { background: none; border: 1px solid #ccc; color: #666; }
.ob-prov { display: flex; justify-content: space-between; align-items: center; }
.ob-add { display: flex; gap: .4rem; margin: .5rem 0; }
.ob-gen { margin-top: .8rem; }
.ob-gen-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }


/* prescription / lab order footer band */
.rx-footer { background: #eef6f1; border-left: 3px solid #0d5c46; border-radius: 6px; padding: .5rem .7rem; margin: .7rem 0 .5rem; font-size: .85rem; display: grid; gap: .15rem; }
.rx-footer .rf-line { color: #3d5249; }
.rx-footer a { color: #0d5c46; }

/* slimmer ID / share toggles */
.pat-id-toggle { font-size: .85rem !important; padding: .45rem .7rem !important; }

.cp-day.cp-disabled, .cp-day:disabled { opacity: .3; cursor: default; pointer-events: none; }
.appt-dual { font-size: .8rem; color: #0d5c46; margin: .15rem 0 .4rem; min-height: 1em; }
.appt-dt-row { display: flex; gap: .4rem; align-items: center; }
.appt-dt-row input[type="text"] { flex: 1; }
#appt-time { padding: .5rem; }

.demo-row { cursor: pointer; }
.demo-row:hover td { background: #eef6f1; }

.demo-chip { border: 1px solid #9fc4b4; background: #fff; color: #0d5c46; border-radius: 6px; padding: .2rem .5rem; margin: .1rem; cursor: pointer; font-size: .8rem; font-family: ui-monospace, monospace; }
.demo-chip:hover { background: #0d5c46; color: #fff; }

.rev-stars { display: flex; gap: .2rem; margin: .5rem 0; }
.rev-stars button { font-size: 1.8rem; background: none; border: none; color: #cbd5d0; cursor: pointer; padding: 0 .1rem; }
.rev-stars button.on { color: #e6a817; }
.dir-rating { color: #e6a817; font-weight: 700; margin-left: .5rem; }
.org-detail { margin-top: .4rem; padding-top: .4rem; border-top: 1px dashed #cfe0d8; }
.rev-line { padding: .1rem 0; }

.day-group { margin: 0.4rem 0; border: 1.5px solid #e2e8f0; border-radius: 8px; padding: .1rem .5rem; }
.day-group[open] { border-color: #0d5c46; background: #f3faf7; box-shadow: 0 0 0 2px rgba(13,92,70,.12); }
.day-group > summary {
  cursor: pointer;
  font-weight: 600;
  color: #0d5c46;
  padding: 0.3rem 0.2rem;
  border-bottom: 1px solid #d8e8e0;
  user-select: none;
}
.day-group[open] > summary { margin-bottom: 0.4rem; }

/* Mobile: anchor profile dropdown to the viewport edge so it can never clip off-screen */
@media (max-width:640px){
  .drop-menu{position:fixed;top:56px;right:16px;left:auto;min-width:220px;
    max-width:calc(100vw - 32px);border:1px solid #d8dee4;
    box-shadow:0 8px 24px rgba(0,0,0,.18)}
}
