@font-face {
  font-family: "Droid Kufi Ar";
  src: url("../fonts/DroidKufi-Regular.woff2") format("woff2"), url("../fonts/DroidKufi-Regular.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}

:root {
  --teal: #13A4B4;
  --teal-600: #0E8794;
  --teal-700: #0C6F7B;
  --teal-900: #08434B;
  --teal-50: #E4F4F5;
  --slate: #3E2723;
  --slate-600: #6D4C41;
  --amber: #FFC53D;
  --bronze: #A2875C;
  --bronze-700: #7A6240;
  --bronze-200: #E2D3B8;
  --bronze-50: #F7F1E7;
  --ink: #142A2E;
  --muted: #5B6F73;
  --page: #EAF2F2;
  --line: #CADCDD;
  --surface: #FFFFFF;
  --alert: #A61B12;
  --alert-bg: #FDE8E6;
  --alert-line: #F2B5AE;
  --font: "Droid Kufi Ar", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --latin: "IBM Plex Sans Arabic", "Segoe UI", Arial, sans-serif;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--page);
}

a { color: var(--teal-700); }
:focus-visible { outline: 3px solid var(--bronze); outline-offset: 2px; }
button, input { font: inherit; }
img { max-width: 100%; }

/* ---------- Masthead ---------- */

.masthead { background: var(--surface); }

.masthead-bar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: block; line-height: 0; }
.brand img { height: 52px; width: auto; }

.archive-span {
  margin-inline-start: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.5;
}
.archive-title { font-size: 17px; color: var(--teal-900); }
.archive-range { font-size: 13px; color: var(--bronze-700); }

.logout {
  font-size: 13px;
  color: var(--teal-900);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 12px;
  text-decoration: none;
}
.logout:hover { background: var(--teal-50); }

.search-band {
  background: var(--teal-900);
  border-top: 3px solid var(--bronze);
}
.search {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px 22px;
}
.is-search .search { padding: 36px 24px 48px; }

.search-label { display: block; font-size: 14px; margin-bottom: 8px; color: #BFE3E6; }
.is-search .search-label { font-size: 22px; color: #fff; margin-bottom: 14px; }

.search-row { display: flex; gap: 10px; max-width: 620px; }
.search input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 16px;
  font-family: var(--latin);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: lining-nums;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}
.search input::placeholder { font-family: var(--font); font-size: 14px; font-weight: 400; color: #8EA3A6; }
.search button {
  height: 50px;
  padding: 0 30px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
}
.search button:hover { background: var(--teal-600); }

/* ---------- Page ---------- */

.page { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px 24px 48px; }

.alert {
  background: var(--alert-bg);
  color: var(--alert);
  border: 1px solid var(--alert-line);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.warn-box {
  margin: 14px 0 0;
  padding: 10px 14px;
  font-size: 14px;
  color: #7A1610;
  background: var(--alert-bg);
  border: 1px solid var(--alert-line);
  border-inline-start: 5px solid #D9483B;
  border-radius: 6px;
}
.warn-box a { color: var(--alert); font-weight: 700; }

.home-hint { max-width: 660px; color: var(--muted); }
.home-hint p { margin: 0 0 6px; }

.timing { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 12px 0 0; font-size: 7.5px; color: var(--muted); }
.timing b { font-family: var(--latin); font-weight: 600; color: var(--teal-700); margin-inline-start: 4px; }

.nat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 20px;
  background: var(--teal-50);
  color: var(--teal-900);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.9;
  vertical-align: middle;
}
.nat img { border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }

.avatar { flex-shrink: 0; }

/* ---------- Chooser ---------- */

.chooser h1 { font-size: 21px; margin: 0 0 8px; color: var(--teal-900); }
.chooser .warn-box { margin: 0 0 16px; max-width: 820px; }
.chooser-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.chooser-item {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) 2fr;
  gap: 18px;
  align-items: center;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 5px solid var(--teal);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
.chooser-item:hover { border-color: var(--teal); background: #FBFEFE; }
.ci-names { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.ci-name { font-size: 18px; color: var(--teal-900); }
.ci-name-en { font-family: var(--latin); font-size: 13px; color: var(--muted); }
.ci-facts { display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 14px; }
.ci-facts span { display: flex; flex-direction: column; }
.ci-facts em { font-style: normal; font-size: 12px; color: var(--muted); }

/* ---------- Patient ---------- */

.patient {
  padding: 20px 24px;
  margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.patient-id { display: flex; align-items: center; gap: 16px; }
.patient-name { margin: 0; font-size: 24px; font-weight: 400; line-height: 1.5; color: var(--teal-900); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.patient-name-en { margin: 0; font-family: var(--latin); color: var(--muted); font-size: 14px; }

.patient-facts { display: flex; flex-wrap: wrap; gap: 6px 30px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid #E3ECEC; }
.patient-facts div { display: flex; flex-direction: column; }
.patient-facts dt { font-size: 12px; color: var(--muted); }
.patient-facts dd { margin: 0; font-size: 15px; }
.patient-facts dd[dir="ltr"] { font-family: var(--latin); font-weight: 600; }

.pf-id dd {
  padding: 0 12px;
  border-radius: 6px;
  background: var(--bronze-50);
  border: 1.5px solid var(--bronze);
  color: var(--teal-900);
  font-size: 17px;
  letter-spacing: .02em;
}

/* ---------- Timeline ---------- */

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  top: 10px; bottom: 10px;
  right: 59px;
  width: 2px;
  background: #C3DDDF;
}

.visit { display: grid; grid-template-columns: 120px 1fr; gap: 22px; margin-bottom: 58px; }

.visit-when {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: start;
  padding: 2px 0 8px;
  text-align: center;
  background: var(--page);
}
.vw-day { font-family: var(--latin); font-size: 40px; font-weight: 400; line-height: 1.05; color: var(--teal-700); }
.vw-month { font-size: 13.5px; color: var(--ink); }
.vw-weekday { font-size: 12px; color: var(--muted); }

.visit-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* High-contrast visit header */
.visit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
  padding: 12px 20px;
  background: #6D4C41;            /* solid colour, no gradient */
  background-image: none;
  color: #fff;
  border-bottom: 3px solid var(--bronze);
}
.visit-head.is-nodoctor { background: linear-gradient(120deg, #111827 0%, #374151 100%); border-bottom-color: #9CA3AF; }
.visit-head.is-nodoctor .vh-date { color: #E5E7EB; }
.visit-head.is-nodoctor .vh-meta em { color: #9CA3AF; }
.vh-main { display: flex; flex-direction: column; }
.vh-doctor { font-size: 20.4px; line-height: 1.6; color: #fff; }
.vh-doctor[dir="auto"] { font-family: var(--font); }
.vh-nodoctor {
  align-self: flex-start;
  padding: 1px 14px;
  border-radius: 20px;
  background: #F3F4F6;
  color: #111827;
  font-size: 15px;
  border: 1px solid #D1D5DB;
}
.vh-alert {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 13px 2px 14px;
  border-radius: 18px;
  background: #FFC53D;
  color: #3B2A00;
  font-size: 16.8px;
  box-shadow: 0 0 0 3px rgba(255, 197, 61, .35);
}
.vh-alert .trophy { color: #3B2A00; flex-shrink: 0; }

.vh-date { font-size: 13.5px; color: #EFEBE9; display: flex; align-items: center; gap: 8px; }
.vh-time {
  font-family: var(--latin);
  padding: 0 8px;
  border-radius: 4px;
  background: var(--bronze);
  color: #fff;
  font-size: 13px;
  line-height: 1.7;
}
.vh-meta { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: 4px 24px; }
.vh-meta span { display: flex; flex-direction: column; }
.vh-meta em { font-style: normal; font-size: 11.5px; color: #D7CCC8; }
.vh-meta b { font-weight: 400; font-size: 14px; }
.vh-meta b[dir="ltr"] { font-family: var(--latin); font-weight: 500; }

/* One block per doctor */
.doctor-block + .doctor-block { border-top: 2px dashed var(--bronze-200); margin-top: 6px; }
.db-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 14px 16px 2px;
  padding: 8px 16px;
  background: antiquewhite;
  border: 1.5px solid #0E8794;
  border-inline-start: 6px solid #08434B;
  border-radius: 10px;
  box-shadow: 0 4px 12px -2px rgba(12, 111, 123, .35), 0 1px 0 rgba(12, 111, 123, .15);
}
.db-doctor { font-size: 18.6px; color: #08434B; }
.db-time { font-family: var(--latin); font-size: 13px; padding: 0 8px; border-radius: 4px; background: var(--slate-600); color: #fff; }
.db-number { font-family: var(--latin); font-size: 12.5px; color: #275A61; margin-inline-start: auto; }

.block { padding: 14px 20px 6px; }
.block[dir="ltr"] { text-align: left; }
.doctor-block .block + .block { border-top: 1px dashed var(--line); }

.block-title {
  margin: 0 0 8px;
  font-family: var(--latin);
  font-size: 18.2px;
  font-weight: 700;
  color: var(--teal-700);
}
.block-title.is-underlined {
  display: inline-block;
  text-decoration: underline;
  text-decoration-color: var(--bronze);
  text-decoration-style: dotted;
  text-decoration-thickness: 3px;
  text-underline-offset: 7px;
  font-size: 20.9px;
  margin-bottom: 12px;
}

.diagnoses { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.dx {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 12px;
  border-radius: 6px;
  border-left: 4px solid;
  font-family: var(--latin);
}
.dx-code { font-weight: 700; min-width: 62px; }
.dx-desc { font-weight: 500; }
.dx-0 { background: #E1F3F5; border-color: var(--teal); }      .dx-0 .dx-code { color: var(--teal-900); }
.dx-1 { background: #F5EDDF; border-color: var(--bronze); }    .dx-1 .dx-code { color: var(--bronze-700); }
.dx-2 { background: #E9EEF7; border-color: #4E6FA8; }          .dx-2 .dx-code { color: #2F4C80; }
.dx-3 { background: #F3E9EE; border-color: #9A5277; }          .dx-3 .dx-code { color: #74385A; }

.notes { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.note {
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 6px;
  font-family: var(--latin);
  font-size: 13.5px;
  line-height: 1.55;
  border: 1px solid transparent;
}
.note-0 { background: #E1F3F5; border-color: #B6DFE3; color: #0A4A52; }
.note-1 { background: #F6EEDF; border-color: #E2D0AE; color: #6A522F; }
.note-2 { background: #EAF0F8; border-color: #C6D4EA; color: #2B4675; }
.note-3 { background: #F4EAEF; border-color: #E2C8D5; color: #6B3352; }
.note-4 { background: #EBF3E8; border-color: #CBDFC3; color: #2F5523; }
.note-5 { background: #F1EEF8; border-color: #D5CDEA; color: #43386B; }
.note-type { margin-right: 6px; font-size: 11px; font-weight: 700; opacity: .7; }

/* Drugs as a prescription slip */
.rx {
  position: relative;
  margin: 2px 0 10px;
  max-width: 720px;
  padding: 10px 18px 27px;
  background: #FFFCF3;
  border: 1px solid #E8DAB9;
  border-top: 4px solid var(--bronze);
  border-radius: 4px 4px 4px 18px;
  box-shadow: 0 1px 0 #E8DAB9, 0 6px 14px -8px rgba(122, 98, 64, .45);
}
.rx::after {
  content: "";
  position: absolute;
  left: -1px; bottom: -1px;
  width: 22px; height: 22px;
  background: linear-gradient(45deg, var(--page) 50%, #EADCBC 50%);
  border-top-right-radius: 4px;
}
.rx-head { display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid #E8DAB9; margin-bottom: 4px; }
.rx-symbol { font-family: Georgia, "Times New Roman", serif; font-size: 30px; line-height: 1; color: var(--bronze); }
.rx .block-title { color: var(--bronze-700); margin: 0; }
.rx-list { margin: 0; padding: 0; list-style: none; font-family: var(--latin); }
.rx-list li { padding: 6px 0 5px; line-height: 1.5; border-bottom: 1px solid #EFE3C9; }
.rx-list li:last-child { border-bottom: 0; }
.rx-list li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 2px; }
.rx-name { font-weight: 700; color: var(--teal-900); margin-right: 10px; }
.rx-dose { color: var(--bronze-700); font-style: italic; font-size: 14px; unicode-bidi: plaintext; }

/* Report buttons */
.visit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
  background: #F6FAFA;
}
.btn-report {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 4px 14px;
  border-radius: 7px;
  font-size: 14px;
  cursor: pointer;
}
.btn-lab { background: #F3EEFF; color: #4C1D95; border: 1.5px solid #8B5CF6; }
.btn-lab:hover { background: #E9E0FF; }
.lab-chip { font-family: var(--latin); font-size: 12px; padding: 0 7px; border-radius: 4px; background: #fff; border: 1px solid #D4C4FB; color: #5B21B6; }
.btn-lab .count {
  font-family: var(--latin);
  min-width: 26px;
  padding: 0 6px;
  border-radius: 10px;
  background: #7C3AED;
  color: #fff;
  font-size: 12px;
  text-align: center;
}
.btn-rad { font-family: var(--latin); font-weight: 600; background: #E6F5F7; color: #0A5560; border: 1.5px solid #13A4B4; }
.btn-rad:hover { background: #D2EEF1; }

.empty-visit { margin: 0; padding: 14px 20px; color: var(--muted); }

/* ---------- Report dialog ---------- */

.report-dialog {
  width: min(980px, 96vw);
  height: 92vh;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(8, 67, 75, .35);
}
.report-dialog[open] { display: flex; flex-direction: column; }
.report-dialog::backdrop { background: rgba(8, 67, 75, .6); }
.rd-bar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--teal-900); color: #fff; }
.rd-bar h2 { margin: 0; font-size: 16px; font-weight: 400; flex: 1; }
.rd-actions { display: flex; gap: 8px; }
.rd-actions button { padding: 4px 16px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .4); background: transparent; color: #fff; cursor: pointer; }
.rd-actions .rd-print { background: var(--bronze); border-color: var(--bronze); }
.rd-frame { flex: 1; width: 100%; border: 0; background: #E6EEEE; }

/* ---------- Portal ---------- */

.portal-head { background: var(--surface); padding: 34px 24px 26px; text-align: center; border-bottom: 3px solid var(--bronze); }
.portal-logo { height: 96px; width: auto; }
.portal { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 40px 24px 56px; }
.portal-title { margin: 0; font-size: 26px; font-weight: 400; color: var(--teal-900); }
.portal-sub { margin: 4px 0 26px; color: var(--muted); }
.services { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.service {
  display: flex;
  gap: 18px;
  padding: 26px 24px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.service-icon {
  flex-shrink: 0;
  width: 84px; height: 84px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-50);
  color: var(--teal-700);
}
.service-text { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.service-name { font-size: 19px; color: var(--teal-900); }
.service-desc { font-size: 14px; color: var(--muted); line-height: 1.8; }
.service-go { margin-top: 6px; padding: 3px 16px; border-radius: 6px; background: var(--teal-700); color: #fff; font-size: 14px; }
.service-archive { border-top: 5px solid var(--teal); }
.service-archive:hover { border-color: var(--teal); box-shadow: 0 10px 24px -14px rgba(8, 67, 75, .5); }
.service-archive:hover .service-go { background: var(--teal-900); }
.service-soon { border: 1px dashed #B7C9CB; border-top: 5px solid var(--bronze-200); background: #F8FBFB; cursor: default; }
.service-soon .service-icon { background: var(--bronze-50); color: var(--bronze); }
.service-soon .service-name { color: var(--muted); }
.badge-soon { margin-top: 6px; padding: 1px 12px; border-radius: 20px; background: var(--bronze-50); color: var(--bronze-700); border: 1px solid var(--bronze-200); font-size: 13px; }

/* ---------- Footer ---------- */

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 24px;
  font-size: 12.5px;
  color: #BFE3E6;
  background: var(--teal-900);
}
.site-footer [dir="ltr"] { font-family: var(--latin); }

/* ---------- Login ---------- */

.is-login { background: var(--teal-900); }
.login { flex: 1; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  padding: 30px 28px;
  background: #fff;
  border-radius: 14px;
  border-top: 5px solid var(--bronze);
}
.login-logo { width: 100%; height: auto; margin-bottom: 4px; }
.login-sub { margin: 4px 0 18px; text-align: center; color: var(--muted); }
.login-card label { font-size: 14px; margin: 10px 0 4px; }
.login-card input { height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--latin); }
.login-card button { margin-top: 20px; height: 46px; border: 0; border-radius: 8px; background: var(--teal-700); color: #fff; cursor: pointer; }
.is-login .site-footer { background: transparent; justify-content: center; }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .masthead-bar { flex-wrap: wrap; padding: 10px 16px; gap: 8px 12px; }
  .brand img { height: 40px; }
  .archive-span { margin-inline-start: 0; align-items: flex-start; flex-direction: row; flex-wrap: wrap; gap: 0 10px; width: 100%; }
  .search { padding: 10px 16px 16px; }
  .is-search .search { padding: 20px 16px 28px; }
  .is-search .search-label { font-size: 18px; }
  .search button { padding: 0 18px; }
  .page { padding: 18px 12px 36px; }
  .patient { padding: 16px; }
  .patient-name { font-size: 20px; }
  .chooser-item { grid-template-columns: auto 1fr; }
  .ci-facts { grid-column: 1 / -1; }
  .timeline::before { display: none; }
  .visit { grid-template-columns: 1fr; gap: 6px; margin-bottom: 44px; }
  .visit-when { flex-direction: row; align-items: baseline; gap: 8px; background: none; padding: 0 4px; }
  .vw-day { font-size: 26px; }
  .vh-meta { margin-inline-start: 0; }
  .block, .visit-head, .visit-actions, .db-head { padding-left: 14px; padding-right: 14px; }
  .portal-logo { height: 64px; }
  .service { flex-direction: column; }
  .report-dialog { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .search-band, .visit-actions, .logout, .report-dialog, .timing { display: none !important; }
  body { background: #fff; }
  .visit { break-inside: avoid; }
}

/* ---------- Visit filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: -8px 0 26px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.f-label { font-size: 14px; color: var(--muted); }
.f-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.f-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
.f-chip .f-count { font-family: var(--latin); font-size: 12px; color: var(--muted); }
.f-chip:hover:not(:disabled) { border-color: var(--slate-600); }
.f-chip[aria-pressed="true"] { background: var(--slate); border-color: var(--slate); color: #fff; }
.f-chip[aria-pressed="true"] .f-count { color: #EFEBE9; }
.f-chip:disabled { opacity: .45; cursor: default; }
.f-doctor { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.f-doctor select {
  height: 34px; min-width: 200px; padding: 0 10px;
  border: 1.5px solid var(--line); border-radius: 8px; background: #fff;
  font-family: var(--latin); font-size: 14px; color: var(--ink);
}
.f-reset { border: 0; background: none; color: var(--alert); font-size: 13px; cursor: pointer; text-decoration: underline; }
.f-result { margin-inline-start: auto; font-size: 13px; color: var(--muted); }
.f-empty { padding: 18px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.visit[hidden] { display: none; }
@media (max-width: 760px) { .f-result { margin-inline-start: 0; width: 100%; } .f-doctor select { min-width: 0; width: 100%; } .f-doctor { width: 100%; } }
@media print { .filters, .f-empty { display: none !important; } }

/* ---------- Chooser helpers ---------- */
.chooser-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 14px; }
.chooser-filter label { font-size: 14px; color: var(--muted); }
.chooser-filter input { height: 38px; min-width: 280px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 14px; }
#name-filter-count { font-size: 13px; color: var(--muted); }
.tag-dup, .tag-bad { font-style: normal; font-size: 11.5px; padding: 0 8px; border-radius: 10px; margin-inline-start: 6px; vertical-align: middle; }
.tag-dup { background: var(--bronze-50); color: var(--bronze-700); border: 1px solid var(--bronze-200); }
.tag-bad { background: var(--alert-bg); color: var(--alert); border: 1px solid var(--alert-line); }
.chooser-item.is-placeholder { border-inline-start-color: #D9483B; }
.chooser-list li[hidden] { display: none; }
.lab-more { font-size: 12.5px; color: #5B21B6; }
.btn-lab { flex-wrap: wrap; text-align: start; }

/* Stethoscope before doctor names */
.vh-doctor, .db-doctor { display: inline-flex; align-items: center; gap: 8px; }
.stetho { flex-shrink: 0; }
.vh-doctor .stetho { color: #FCD34D; width: 24px; height: 24px; }
.db-doctor .stetho { color: #08434B; }   /* same colour as the doctor name */

/* Time chip readable on the bronze end of the header gradient */
.vh-time { background: rgba(17, 24, 39, .55); color: #F3E8D2; }

.info-box {
  margin: 14px 0 0;
  padding: 8px 14px;
  font-size: 14px;
  color: #1F2937;
  background: #F3F4F6;
  border: 1px solid #D1D5DB;
  border-inline-start: 5px solid #6B7280;
  border-radius: 6px;
}
.info-box b { font-family: var(--latin); }

/* Copy buttons in the prescription */
.copy-btn {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 20px; height: 20px;
  margin: 0 8px 0 0;
  padding: 0;
  align-self: center;
  border: 1px solid #E0D2B4;
  border-radius: 5px;
  background: #fff;
  color: var(--bronze-700);
  cursor: pointer;
}
.copy-btn svg { width: 13px; height: 13px; }
.copy-btn:hover { background: var(--bronze-50); border-color: var(--bronze); }
.copy-btn .ic-done { display: none; }
.copy-btn.is-done { background: #E8F5E9; border-color: #66BB6A; color: #2E7D32; }
.copy-btn.is-done .ic-copy { display: none; }
.copy-btn.is-done .ic-done { display: block; }
@media print { .copy-btn { display: none !important; } }

.services.is-single { grid-template-columns: minmax(300px, 560px); justify-content: center; }

.warn-caution { display: block; margin-top: 4px; font-weight: 700; }

/* Shared ID number: short blinking warning with a button to the list of names */
.warn-shared {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 14px 0 0; padding: 10px 14px;
  font-size: 14px; font-weight: 700; color: #7A1610;
  background: #FDECEA; border: 1px solid #F3B8B1; border-inline-start: 5px solid #D9483B; border-radius: 6px;
  animation: ws-blink 1.1s ease-in-out infinite;
}
.warn-shared .ws-text { flex: 1 1 320px; }
.warn-shared .ws-btn {
  flex: none; display: inline-block; padding: 5px 14px; border-radius: 6px;
  background: #C62828; color: #fff; font-size: 13px; font-weight: 700; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.warn-shared .ws-btn:hover, .warn-shared .ws-btn:focus-visible { background: #8E1B1B; color: #fff; }
@keyframes ws-blink {
  0%, 100% { background: #FDECEA; border-color: #F3B8B1; box-shadow: 0 0 0 0 rgba(217,72,59,0); }
  50%      { background: #F9C6BF; border-color: #D9483B; box-shadow: 0 0 0 4px rgba(217,72,59,.28); }
}
@media print { .warn-shared { animation: none; } .warn-shared .ws-btn { display: none; } }

/* ---------- Access log page (stats.php) ---------- */
.stats { display: grid; gap: 18px; }
.st-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; }
.st-presets { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.st-chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; background: #fff; }
.st-chip.is-on { background: var(--teal-900); border-color: var(--teal-900); color: #fff; }
.st-filter label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.st-filter input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.st-filter button { font: inherit; padding: 6px 18px; border: 0; border-radius: 6px; background: var(--teal-600); color: #fff; cursor: pointer; }
.st-export { margin-inline-start: auto; color: var(--teal-700); font-weight: 700; }
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.st-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.st-tile b { font-size: 26px; color: var(--teal-900); font-family: var(--latin); }
.st-tile span { color: var(--muted); font-size: 13px; }
.st-tile.st-range b { font-size: 14px; color: var(--ink); }
.st-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.st-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; }
.st-card h2 { margin: 0 0 10px; font-size: 16px; color: var(--teal-900); }
.st-card h2 + .st-table, .st-hours + h2 { margin-top: 0; }
.st-hours + h2 { margin-top: 18px; }
.st-note { font-size: 12px; color: var(--muted); font-weight: 400; }
.st-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.st-table th { text-align: start; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); padding: 6px 8px; white-space: nowrap; }
.st-table td { border-bottom: 1px solid #E3ECEC; padding: 6px 8px; white-space: nowrap; }
.st-table a { color: var(--teal-700); text-decoration: none; }
.st-table a:hover { text-decoration: underline; }
.st-barcell { position: relative; min-width: 110px; }
.st-bar { position: absolute; inset-block: 6px; inset-inline-start: 0; background: var(--teal-50); border-inline-end: 3px solid var(--teal); border-radius: 3px; }
.st-barcell b { position: relative; padding-inline-start: 6px; }
.st-hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; height: 130px; align-items: end; }
.st-hour { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.st-hbar { width: 100%; background: var(--teal); border-radius: 3px 3px 0 0; }
.st-hour i { font-style: normal; font-size: 10px; color: var(--muted); margin-top: 3px; font-family: var(--latin); }
.st-empty { color: var(--muted); }

/* ---------- Statistics page: tabs, doctor statistics, sortable tables ---------- */
.stats-btn {
  margin-inline-start: auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: #3B2A00; text-decoration: none;
  background: var(--amber); border: 1px solid #E0A800; border-radius: 6px; padding: 4px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.stats-btn svg { width: 16px; height: 16px; }
.stats-btn:hover, .stats-btn:focus-visible { background: #FFB300; color: #2A1E00; }
.st-tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); }
.st-tab {
  padding: 9px 22px; font-size: 15px; font-weight: 700; color: var(--muted); text-decoration: none;
  border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; margin-bottom: -2px;
}
.st-tab:hover { color: var(--teal-900); background: var(--teal-50); }
.st-tab.is-on { color: var(--teal-900); background: var(--surface); border-color: var(--line); border-bottom: 2px solid var(--surface); }
.st-panel { display: grid; gap: 18px; }
.st-panel[hidden] { display: none; }
.ds-period { margin: 0; padding: 10px 14px; background: var(--bronze-50); border: 1px solid var(--bronze-200); border-inline-start: 5px solid var(--bronze); border-radius: 6px; font-size: 14px; color: var(--bronze-700); }
.ds-period b { color: var(--slate); }
.ds-notes { margin: 12px 0 0; padding-inline-start: 18px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.ds-pick { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0 14px; font-size: 13px; color: var(--muted); }
.ds-pick select, .st-filter select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.ds-doc { margin-bottom: 18px; }
.ds-doc[hidden] { display: none; }
.ds-doc h3 { margin: 0 0 8px; font-size: 15px; color: var(--slate); text-align: start; }
.ds-doc h3 span { font-weight: 400; font-size: 12px; color: var(--muted); }
.tbl-wrap { overflow-x: auto; }
.st-table tfoot td { font-weight: 700; background: #FFF4D6; border-top: 2px solid var(--bronze-200); padding: 6px 8px; white-space: nowrap; }
.st-table .t-desc { white-space: normal; min-width: 260px; text-align: left; }
.st-table .t-name { font-weight: 700; text-align: left; }
.st-table .t-wrap { white-space: normal; max-width: 220px; }
.st-table th.is-sortable { cursor: pointer; user-select: none; }
.st-table th.is-sortable::after { content: ' ⇅'; color: #B9C7C8; font-size: 11px; }
.st-table th[aria-sort="ascending"]::after { content: ' ▲'; color: var(--teal); }
.st-table th[aria-sort="descending"]::after { content: ' ▼'; color: var(--teal); }
.st-table th.is-sortable:hover { color: var(--teal-900); }
.dev-name { display: flex; gap: 4px; }
.dev-name input { font: inherit; font-size: 12px; width: 130px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; }
.dev-name button { font: inherit; font-size: 12px; padding: 3px 10px; border: 0; border-radius: 5px; background: var(--teal-600); color: #fff; cursor: pointer; }
@media (max-width: 640px) { .st-tab { padding: 8px 12px; font-size: 13px; } }

/* Doctor statistics: sub-tabs and charts */
.ds-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.ds-tab {
  font: inherit; font-size: 13px; cursor: pointer; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.ds-tab:hover { border-color: var(--teal); color: var(--teal-900); }
.ds-tab.is-on { background: var(--teal-900); border-color: var(--teal-900); color: #fff; }
.ds-panel[hidden] { display: none; }
.ds-chart { display: block; width: 100%; height: auto; margin: 6px 0 16px; font-family: var(--latin); }
.ds-bar:hover rect[rx] { opacity: .8; }
.ds-ch { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.ds-tag { display: inline-block; margin-inline-start: 6px; padding: 0 6px; font-size: 10px; font-weight: 700; border-radius: 4px; background: var(--bronze-50); color: var(--bronze-700); border: 1px solid var(--bronze-200); }
.ds-tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 360px;
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1.5; padding: 6px 10px; border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.ds-tip[hidden] { display: none; }
.ds-chart text { direction: ltr; unicode-bidi: plaintext; }

/* v23: equal main tabs, zebra rows, larger text in doctor statistics */
.st-tab { min-width: 190px; text-align: center; box-sizing: border-box; line-height: 1.5; border: 1px solid transparent; border-bottom: 2px solid transparent; }
.st-tab.is-on { border-color: var(--line); border-bottom: 2px solid var(--surface); }
.st-table tbody tr:nth-child(odd) td { background: #FFFFFF; }
.st-table tbody tr:nth-child(even) td { background: #EEF6F7; }
.st-table tbody tr:hover td { background: #DDF1F4; }
#panel-doctors .ds-tab { font-size: 15px; }
#panel-doctors .ds-period { font-size: 16px; }
#panel-doctors .st-card h2 { font-size: 18.5px; }
#panel-doctors .ds-doc h3 { font-size: 17px; }
#panel-doctors .ds-doc h3 span, #panel-doctors .st-note, #panel-doctors .ds-pick, #panel-doctors .ds-ch { font-size: 14px; }
#panel-doctors .st-table { font-size: 15px; }
#panel-doctors .ds-tag { font-size: 11.5px; }

/* v27: palette #425B9A (navy), #76C0EC (sky), #FFF6DC (cream), #FF95A5 (pink) with black for the statistics page.
   Main tabs are two fixed-size buttons (same box in both states). */
.is-stats { --p-navy: #425B9A; --p-sky: #76C0EC; --p-cream: #FFF6DC; --p-pink: #FF95A5; --p-black: #000000; }
.is-stats .st-tabs { display: flex; gap: 10px; border-bottom: 0; padding: 0; }
.is-stats .st-tab, .is-stats .st-tab.is-on {
  display: inline-flex; align-items: center; justify-content: center;
  width: 210px; min-width: 0; height: 46px; margin: 0; padding: 0 12px; box-sizing: border-box;
  font-size: 15px; font-weight: 700; line-height: 1; text-decoration: none;
  border: 2px solid var(--p-black); border-radius: 10px; background: #FFFFFF; color: var(--p-black);
}
.is-stats .st-tab:hover { background: var(--p-cream); color: var(--p-black); }
.is-stats .st-tab.is-on, .is-stats .st-tab.is-on:hover { background: var(--p-black); color: var(--p-cream); border-color: var(--p-black); }
@media (max-width: 640px) { .is-stats .st-tab, .is-stats .st-tab.is-on { width: auto; flex: 1 1 0; font-size: 13px; } }

.is-stats .st-card { border-color: #E2E6EF; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.is-stats .st-card h2 { color: var(--p-black); padding-inline-start: 10px; border-inline-start: 5px solid var(--p-pink); }
.is-stats .st-note { color: #3A3A3A; }
.is-stats .ds-doc h3 { color: var(--p-black); }
.is-stats .ds-ch { color: var(--p-navy); }
.is-stats .ds-period { background: var(--p-cream); border-color: var(--p-sky); border-inline-start-color: var(--p-navy); color: var(--p-black); }
.is-stats .ds-period b { color: var(--p-navy); }

.is-stats .st-table th { background: var(--p-navy); color: #FFFFFF; border-bottom: 3px solid var(--p-pink); padding: 8px 10px; }
.is-stats .st-table thead th:first-child { border-start-start-radius: 8px; }
.is-stats .st-table thead th:last-child  { border-start-end-radius: 8px; }
.is-stats .st-table th.is-sortable::after { color: var(--p-sky); opacity: 1; }
.is-stats .st-table th[aria-sort]::after { color: var(--p-cream); }
.is-stats .st-table th.is-sortable:hover { color: var(--p-cream); background: var(--p-black); }
.is-stats .st-table td { border-bottom: 1px solid #ECEEF3; padding: 7px 10px; color: var(--p-black); }
.is-stats .st-table tbody tr:nth-child(odd) td  { background: #FFFFFF; }
.is-stats .st-table tbody tr:nth-child(even) td { background: var(--p-cream); }
.is-stats .st-table tbody tr:hover td { background: #DDF0FB; }
.is-stats .st-table a { color: var(--p-navy); font-weight: 700; }
.is-stats .st-table tfoot td { background: #DDF0FB; border-top: 2px solid var(--p-navy); color: var(--p-black); }

.is-stats .ds-tab { border-color: #CFD6E4; color: var(--p-black); }
.is-stats .ds-tab:hover { border-color: var(--p-navy); color: var(--p-black); }
.is-stats .ds-tab.is-on { background: var(--p-navy); border-color: var(--p-navy); color: #FFFFFF; }
.is-stats .ds-tag { background: var(--p-cream); color: var(--p-navy); border-color: var(--p-sky); }
.is-stats .st-chip.is-on { background: var(--p-black); border-color: var(--p-black); color: var(--p-cream); }
.is-stats .st-filter button, .is-stats .dev-name button { background: var(--p-navy); }
.is-stats .st-export { color: var(--p-navy); }
.is-stats .st-tile { border-top: 4px solid var(--p-pink); }
.is-stats .st-tile b { color: var(--p-navy); }
.is-stats .st-bar { background: #DDF0FB; border-inline-end-color: var(--p-navy); }
.is-stats .st-hbar { background: linear-gradient(to top, var(--p-navy), var(--p-sky)); }
.ds-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Doctor visits: buttons beside the chart switch between the columns */
.ds-switch { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.ds-mbtns { flex: 0 0 230px; display: flex; flex-direction: column; gap: 8px; padding-top: 30px; }
.ds-mbtn {
  display: flex; align-items: center; gap: 10px; width: 100%; box-sizing: border-box;
  font: inherit; font-size: 14px; font-weight: 700; text-align: start; cursor: pointer;
  padding: 10px 12px; border: 2px solid #D0D0D0; border-radius: 10px; background: #FFFFFF; color: var(--p-black, #000);
}
.ds-mbtn i { flex: none; width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.ds-mbtn:hover { border-color: var(--p-black, #000); }
.ds-mbtn.is-on { background: var(--p-black, #000); border-color: var(--p-black, #000); color: var(--p-cream, #FFF6DC); }
.ds-mbtn.is-on i { box-shadow: 0 0 0 2px #FFFFFF; }
.ds-mcharts { flex: 1 1 auto; min-width: 0; }
.ds-mchart { margin: 0; }
.ds-mchart[hidden] { display: none; }
.ds-mchart .ds-r { transform-box: fill-box; transform-origin: left center; animation: ds-grow .45s ease-out; }
@keyframes ds-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .ds-mchart .ds-r { animation: none; } }
@media (max-width: 800px) {
  .ds-switch { flex-direction: column; }
  .ds-mbtns { flex: none; flex-direction: row; flex-wrap: wrap; padding-top: 0; width: 100%; }
  .ds-mbtn { width: auto; }
}
#panel-doctors .ds-mbtn { font-size: 15px; }

/* v28: doctor statistics sub-tabs on one line */
#panel-doctors .ds-tabs { flex-wrap: nowrap; gap: 4px; overflow-x: auto; scrollbar-width: thin; }
#panel-doctors .ds-tab { flex: 0 0 auto; white-space: nowrap; font-size: 13px; padding: 6px 11px; }

/* v29: gold text on every black background */
.is-stats { --p-gold: #FFD700; }
.is-stats .st-tab.is-on, .is-stats .st-tab.is-on:hover { color: var(--p-gold); }
.is-stats .st-chip.is-on { color: var(--p-gold); }
.is-stats .ds-mbtn.is-on { color: var(--p-gold); }
.is-stats .ds-mbtn.is-on i { box-shadow: 0 0 0 2px var(--p-gold); }
.is-stats .st-table th.is-sortable:hover { color: var(--p-gold); }
.is-stats .ds-tip { background: #000000; color: var(--p-gold); }
/* v30: brighter gold with a soft glow on black */
.is-stats .st-tab.is-on, .is-stats .st-chip.is-on, .is-stats .ds-mbtn.is-on { text-shadow: 0 0 6px rgba(255,215,0,.45); }

/* v33: nationalities & specialties */
.ds-segbox { display: grid; gap: 12px; }
.ds-seg { display: inline-flex; gap: 0; border: 2px solid #000; border-radius: 10px; overflow: hidden; width: max-content; }
.ds-segbtn { font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; padding: 8px 22px; border: 0; background: #FFFFFF; color: #000; }
.ds-segbtn + .ds-segbtn { border-inline-start: 2px solid #000; }
.ds-segbtn:hover { background: var(--p-cream, #FFF6DC); }
.ds-segbtn.is-on { background: #000; color: var(--p-gold, #FFD700); text-shadow: 0 0 6px rgba(255,215,0,.45); }
.ds-segp[hidden] { display: none; }
.ds-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: #000; margin: 4px 0 2px; }
.ds-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ds-legend i, .ds-sw { display: inline-block; flex: none; width: 13px; height: 13px; border-radius: 3px; vertical-align: -2px; margin-inline-end: 6px; }
.ds-legend i { margin: 0; }
.st-table td small { color: #555; font-size: 0.85em; margin-inline-start: 3px; }
.ds-cls { border: 1px solid #E2E6EF; border-radius: 8px; padding: 8px 12px; margin-top: 6px; background: #fff; }
.ds-cls summary { cursor: pointer; font-size: 14px; }
.ds-cls ul { margin: 8px 0 2px; padding-inline-start: 18px; font-size: 13px; line-height: 1.8; columns: 2 320px; }
.ds-cls li span { font-family: var(--latin); }
#panel-doctors .ds-legend { font-size: 14px; }
#panel-doctors .ds-segbtn { font-size: 15px; }
.ds-segbox { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.ds-segp { min-width: 0; }
.ds-panel, .ds-panel > .st-card { min-width: 0; }
