* { box-sizing: border-box; margin: 0; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
}
header {
  background: #0d5c46;
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header h1 { font-size: 1.4rem; }
#user-badge { display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
[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 { max-width: 720px; margin: 1.5rem auto; padding: 0 1rem; display: grid; gap: 1rem; }
.card {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card h2 { font-size: 1.1rem; margin-bottom: .75rem; }
input, select {
  display: block;
  width: 100%;
  padding: .6rem;
  margin-bottom: .6rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: .95rem;
}
button {
  background: #0d5c46;
  color: #fff;
  border: 0;
  padding: .65rem 1.2rem;
  border-radius: 6px;
  font-size: .95rem;
  cursor: pointer;
}
button:hover { background: #0a4a38; }
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; }
.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; }
.tab {
  background: #e2e8f0;
  color: #4a5568;
  padding: .5rem 1.1rem;
  font-size: .9rem;
  border-radius: 6px 6px 0 0;
}
.tab:hover { background: #cbd5e0; }
.tab.active { background: #0d5c46; color: #fff; }

/* Nested sub-tabs (doctor view) */
.subtabs { margin-top: .75rem; margin-bottom: .75rem; }
.subtabs .tab { padding: .35rem .9rem; font-size: .82rem; }

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; }
.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: 0;
  top: calc(100% + .4rem);
  z-index: 20;
  min-width: 240px;
  text-align: left;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  padding: 1rem;
}
#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;
}
#profile-menu > div:last-of-type { display: flex; gap: .4rem; margin-top: .5rem; }

/* Search modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-card { width: 100%; max-width: 440px; margin: 0; }
.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; }
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;
}
