/* DocScribe dashboard.
   The idea: what the voice note produced is held in brackets (the logo's brackets)
   until the doctor checks it. Teal = heard by the machine. Blue ink = checked by the doctor.
   Red = allergies and red flags. Amber = please verify. */

:root {
  --paper: #F4F2EC;
  --sheet: #FFFFFF;
  --ink: #0A0A0A;
  --ink-2: #2E2D29;
  --muted: #625F57;
  --line: #DAD6CB;
  --line-2: #E9E6DE;

  --teal: #14B8A6;          /* brand teal: decoration and dark grounds only */
  --teal-deep: #0F766E;     /* teal text on light: 5.4:1 on white */
  --teal-soft: #E2F4F1;

  --checked: #1D3A8F;       /* the doctor's pen */
  --checked-soft: #E7EBF7;

  --danger: #B42318;
  --danger-soft: #FCEBE9;
  --verify: #8A4B06;        /* amber text: 6.3:1 on its soft */
  --verify-line: #D98A1C;
  --verify-soft: #FDF1DC;

  --night: #0A0A0A;
  --night-2: #1A1A18;

  --focus: #0A0A0A;
  --chamfer: 12px;
  --radius: 0;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ar: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .1, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-variation-settings: "wdth" 100;
  font-variant-numeric: tabular-nums;
}
:lang(ar), [dir="rtl"] body { font-family: var(--font-ar); }
[lang="ar"] { font-family: var(--font-ar); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip {
  position: absolute; inset-inline-start: var(--s4); top: -60px; z-index: 30;
  background: var(--sheet); padding: var(--s2) var(--s3); font-weight: 600;
}
.skip:focus { top: var(--s2); }

/* ---------- Display type ---------- */
.display {
  font-variation-settings: "wdth" 112;
  font-weight: 680;
  letter-spacing: -0.015em;
  line-height: 1.05;
}
[dir="rtl"] .display { font-family: var(--font-ar); letter-spacing: 0; font-weight: 700; }

/* ---------- The bracket: the product's one shape ---------- */
/* Inline: wraps a status or an item still to check, like an editor's insertion. */
.br {
  position: relative;
  display: inline-block;
  padding: 1px .6em;
  line-height: 1.35;
}
.br::before, .br::after {
  content: "";
  position: absolute; top: 0; bottom: 0; width: .32em;
  border: 2px solid currentColor;
}
.br::before { inset-inline-start: 0; border-inline-end: 0; }
.br::after { inset-inline-end: 0; border-inline-start: 0; }

.status { font-size: 14px; font-weight: 600; white-space: nowrap; }
.status--draft { color: var(--teal-deep); }
.status--checked { color: var(--checked); display: inline-flex; align-items: center; gap: 6px; }
.status--checked svg { width: 14px; height: 14px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--night);
  color: #F4F2EC;
  position: relative; z-index: 5;
}
.topbar::after {             /* the flat line the pulse spikes from */
  content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 2px; background: var(--teal);
}
.topbar__in {
  max-width: 1280px; margin: 0 auto; padding: 0 var(--s5);
  height: 64px; display: flex; align-items: center; gap: var(--s6);
}
.topbar__logo { display: block; height: 30px; }
.topbar__logo img { height: 30px; width: auto; display: block; }
.nav { display: flex; gap: var(--s2); height: 100%; }
.nav a {
  position: relative; display: flex; align-items: center; height: 100%;
  padding: 0 var(--s3); text-decoration: none; font-weight: 550; color: #CFCBC0;
}
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: #fff; }
.nav a[aria-current="page"]::after {   /* the logo's pulse, crossing the teal line */
  content: ""; position: absolute; left: 50%; bottom: -9px; width: 44px; height: 30px; margin-left: -22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 30'%3E%3Cpath d='M0 20h12l5-14 6 22 4-8h17' fill='none' stroke='%2314B8A6' stroke-width='2.4'/%3E%3C/svg%3E") no-repeat center / 44px 30px;
  z-index: 2;
}
.nav a:focus-visible { outline-color: #fff; outline-offset: -6px; }
.topbar__user { margin-inline-start: auto; display: flex; align-items: center; gap: var(--s4); font-size: 14px; color: #CFCBC0; }
.topbar__user a { color: #CFCBC0; }
.topbar__user a:focus-visible { outline-color: #fff; }

/* Phone tab bar */
.tabs { display: none; }

/* ---------- Page frame ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: var(--s6) var(--s5) var(--s8); }
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 var(--s4); display: flex; gap: var(--s2); flex-wrap: wrap; }
.crumbs a { color: var(--ink-2); }
.crumbs span[aria-hidden] { color: var(--line); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s5);
  border: 2px solid var(--ink); background: transparent; color: var(--ink);
  font-weight: 620; text-decoration: none; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}
[dir="rtl"] .btn { clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px); }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn--sign { background: var(--checked); border-color: var(--checked); color: #fff; }
.btn--sign:hover { background: #142B6E; border-color: #142B6E; color: #fff; }
.btn--quiet { border-color: transparent; text-decoration: underline; text-underline-offset: 3px; padding: 0 var(--s2); clip-path: none; }
.btn--quiet:hover { background: transparent; color: var(--ink); }
.btn svg { width: 18px; height: 18px; }
/* clip-path would cut off the outline, so focus draws inside */
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: -7px; }
.btn--sign:focus-visible { outline-color: #fff; }

/* ======================================================
   PATIENTS LIST
   ====================================================== */
.list-head { display: flex; align-items: baseline; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.list-head h1 { font-size: 44px; margin: 0; }
.list-head p { margin: 0; color: var(--muted); }

/* Search held between the logo's brackets */
.find {
  position: relative;
  display: grid; grid-template-columns: 26px 1fr 26px; align-items: stretch; height: 76px;
  max-width: 880px; margin: 0 0 var(--s6);
}
.find__br { width: 26px; height: 76px; display: block; color: var(--ink); transition: transform .35s var(--ease), color .2s; }
.find__br path { fill: currentColor; }
.find__br--end { transform: scaleX(-1); }
.find input {
  width: 100%; min-height: 76px; border: 0; background: transparent;
  font-size: 26px; font-variation-settings: "wdth" 108; font-weight: 500;
  padding: 0 var(--s3); outline: none;
}
.find input::placeholder { color: #8C887E; }
.find__key {
  position: absolute; inset-inline-end: 52px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--muted); border: 1.5px solid var(--line); padding: 1px 7px;
}
.find:focus-within .find__br { color: var(--teal-deep); }
.find:focus-within .find__br--start { transform: translateX(8px); }
.find:focus-within .find__br--end { transform: scaleX(-1) translateX(8px); }
[dir="rtl"] .find__br--start { transform: scaleX(-1); }
[dir="rtl"] .find__br--end { transform: none; }
[dir="rtl"] .find:focus-within .find__br--start { transform: scaleX(-1) translateX(8px); }
[dir="rtl"] .find:focus-within .find__br--end { transform: translateX(8px); }
.find:focus-within .find__key { display: none; }
.find input::-webkit-search-cancel-button { display: none; }

/* Recordings without a patient */
.orphans {
  display: flex; gap: var(--s4); align-items: center; flex-wrap: wrap;
  background: var(--verify-soft); color: var(--ink);
  padding: var(--s4) var(--s5); margin-bottom: var(--s6);
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, 0 100%);
}
[dir="rtl"] .orphans { clip-path: polygon(var(--chamfer) 0, 100% 0, 100% 100%, 0 100%, 0 var(--chamfer)); }
.orphans svg { width: 28px; height: 20px; flex: none; color: var(--verify); }
.orphans p { margin: 0; flex: 1 1 320px; }
.orphans strong { font-weight: 650; }
.orphans a.btn { min-height: 40px; }

/* Rows */
.plist { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.plist__cols {
  display: grid; grid-template-columns: minmax(220px, 1.3fr) minmax(150px, .9fr) minmax(220px, 1.4fr) 170px 150px;
  gap: var(--s5); padding: var(--s2) var(--s4); font-size: 13px; color: var(--muted); font-weight: 550;
}
.prow {
  position: relative;
  display: grid; grid-template-columns: minmax(220px, 1.3fr) minmax(150px, .9fr) minmax(220px, 1.4fr) 170px 150px;
  gap: var(--s5); align-items: center;
  padding: var(--s4); background: var(--sheet); border-bottom: 1px solid var(--line);
}
.prow:hover { background: #FBFAF7; }
.prow:focus-within { outline: 3px solid var(--focus); outline-offset: -3px; }
.prow__name a { text-decoration: none; font-weight: 650; font-size: 19px; font-variation-settings: "wdth" 106; }
.prow__name a::after { content: ""; position: absolute; inset: 0; }   /* whole row clicks */
.prow__name a:focus-visible { outline: none; }
.prow__meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.prow__meta bdi { unicode-bidi: isolate; }
.prow__allergy { font-size: 14px; font-weight: 650; color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.prow__allergy svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.prow__none { font-size: 14px; color: var(--muted); }
.prow__last { font-size: 15px; }
.prow__last time { display: block; font-size: 13px; color: var(--muted); }
.prow__status { justify-self: start; }

/* The file's trace: one pulse per visit over six months */
.trace { width: 170px; height: 30px; display: block; overflow: visible; }
.trace .base { stroke: var(--line); stroke-width: 1.5; }
.trace .beat { fill: none; stroke-width: 2; stroke-linejoin: miter; }
.trace .beat--draft { stroke: var(--teal-deep); }
.trace .beat--checked { stroke: var(--checked); }
.trace text { font-size: 9px; fill: var(--muted); font-family: var(--font); }
[dir="rtl"] .trace .flip { transform: scaleX(-1); transform-origin: 85px 0; }

.empty {
  background: var(--sheet); padding: var(--s7) var(--s5); text-align: center; border-bottom: 1px solid var(--line);
}
.empty h2 { margin: 0 0 var(--s2); font-size: 22px; }
.empty p { margin: 0 auto; color: var(--muted); max-width: 46ch; }

/* ======================================================
   PATIENT PROFILE
   ====================================================== */
.phead { display: flex; flex-wrap: wrap; gap: var(--s4) var(--s6); align-items: flex-end; justify-content: space-between; margin-bottom: var(--s5); }
.phead h1 { font-size: 64px; margin: 0; }
.phead__meta { margin: var(--s2) 0 0; color: var(--ink-2); font-size: 17px; }
.phead__meta span + span::before { content: "·"; margin: 0 .5em; color: var(--muted); }

/* Safety band: never decoration */
.safety { display: grid; gap: var(--s3); margin-bottom: var(--s6); }
.safety--row { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.alert {
  display: grid; grid-template-columns: 26px 1fr; gap: var(--s3); align-items: start;
  padding: var(--s4) var(--s5);
  font-size: 16px;
}
.alert svg { width: 22px; height: 22px; margin-top: 2px; }
.alert h2, .alert h3 { margin: 0; font-size: 15px; font-weight: 700; }
.alert ul { margin: 2px 0 0; padding: 0; list-style: none; }
.alert li { font-weight: 600; }
.alert--flag { background: var(--danger); color: #fff; }
.safety .alert--flag h2, .safety .alert--flag h3 { color: #fff; }
.alert--allergy { background: var(--danger-soft); color: var(--danger); outline: 2px solid var(--danger); outline-offset: -2px; }
.alert--allergy li { color: #7A160F; }
.alert--verify { background: var(--verify-soft); color: var(--verify); }
.alert--verify li { color: var(--ink); font-weight: 550; }
.alert--verify li .br { color: var(--verify); }
/* No allergy extracted: deliberately quiet and unlike the allergy alert, so it never reads as "no known allergies". */
.unstated {
  display: grid; grid-template-columns: 26px 1fr; gap: var(--s3); align-items: start;
  padding: var(--s4) var(--s5);
  background: var(--sheet); color: var(--ink-2); font-size: 15px;
  border: 1px solid var(--line);
}
.unstated svg { width: 22px; height: 22px; margin-top: 1px; color: var(--muted); }
.unstated h2 { margin: 0; font-size: 15px; font-weight: 650; color: var(--ink); }
.unstated p { margin: 2px 0 0; }

.pgrid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s7); align-items: start; }
.pgrid > * { min-width: 0; }
.pgrid h2.h { font-size: 22px; margin: 0 0 var(--s4); font-variation-settings: "wdth" 108; font-weight: 660; }

/* The file: a vertical line, each visit a beat crossing it */
.spine { list-style: none; margin: 0; padding: 0; position: relative; }
.spine::before {
  content: ""; position: absolute; top: 8px; bottom: 8px; inset-inline-start: 27px; width: 2px; background: var(--ink);
  transform-origin: top; animation: spine-draw .9s var(--ease) .15s both;
}
.beat-item { position: relative; padding-inline-start: 72px; padding-bottom: var(--s5); }
.beat-item__mark {
  position: absolute; inset-inline-start: 0; top: 10px; width: 56px; height: 30px; color: var(--ink);
}
.beat-item__mark path { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: miter; }
.beat-item__mark rect { fill: var(--paper); }
.beat-item--draft .beat-item__mark { color: var(--teal-deep); }
[dir="rtl"] .beat-item__mark { transform: scaleX(-1); }
.visit-card { background: var(--sheet); padding: var(--s5); border: 1px solid var(--line); }
.visit-card--latest { border: 2px solid var(--ink); }
.visit-card__top { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: baseline; justify-content: space-between; }
.visit-card__date { font-weight: 650; font-size: 18px; }
.visit-card__date small { font-weight: 450; color: var(--muted); font-size: 14px; margin-inline-start: var(--s2); }
.visit-card__complaint { font-size: 20px; margin: var(--s2) 0 var(--s3); font-variation-settings: "wdth" 104; font-weight: 560; }
.visit-card__summary { color: var(--ink-2); margin: 0 0 var(--s4); max-width: 68ch; }
.visit-card__state { margin: 0 0 var(--s4); max-width: 68ch; }
.note .note__draft { margin: 0 0 var(--s4); color: var(--ink-2); font-size: 15px; }
.note .note__disclaimer { margin: 0 0 var(--s3); padding: var(--s2) var(--s3); font-size: 14px; font-weight: 600; color: var(--verify); background: var(--verify-soft); border: 1px solid var(--verify-line); }
.visit-card__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); margin: 0 0 var(--s4); }
.visit-card__facts dt { font-size: 13px; color: var(--muted); font-weight: 600; }
.visit-card__facts dd { margin: 2px 0 0; }
.visit-card__facts ul { margin: 0; padding: 0; list-style: none; }
.visit-card__open { font-weight: 650; }
details.visit-card summary { cursor: pointer; list-style: none; }
details.visit-card summary::-webkit-details-marker { display: none; }
details.visit-card summary .chev { transition: transform .2s; display: inline-block; }
details.visit-card[open] summary .chev { transform: rotate(90deg); }
[dir="rtl"] details.visit-card summary .chev { transform: scaleX(-1); }
[dir="rtl"] details.visit-card[open] summary .chev { transform: rotate(90deg); }
details.visit-card summary .visit-card__complaint { margin-bottom: 0; }
details.visit-card[open] summary .visit-card__complaint { margin-bottom: var(--s3); }

.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); min-width: 0; }
.panel { background: var(--sheet); padding: var(--s5); border: 1px solid var(--line); min-width: 0; overflow-wrap: break-word; }
.panel h2 { margin: 0 0 var(--s3); font-size: 17px; font-weight: 680; }
.panel ul { list-style: none; margin: 0; padding: 0; }
.panel li { padding: var(--s2) 0; border-top: 1px solid var(--line-2); display: flex; justify-content: space-between; gap: var(--s3); }
.panel li:first-child { border-top: 0; padding-top: 0; }
.panel li small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.panel li b { font-weight: 600; }
.panel li span.dose { display: block; font-size: 14px; color: var(--ink-2); }
.vtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.vtable th, .vtable td { text-align: start; padding: 6px 8px 6px 0; white-space: nowrap; border-top: 1px solid var(--line-2); }
.vtable thead th { color: var(--muted); font-weight: 600; border-top: 0; }
.vtable tbody tr:first-child td { font-weight: 650; font-size: 15px; }
.vtable td:first-child { white-space: nowrap; color: var(--muted); font-weight: 500; font-size: 13px; }
.beat-item:not(.beat-item--draft) .beat-item__mark { color: var(--checked); }

/* ======================================================
   VISIT
   ====================================================== */
.vhead { display: flex; flex-wrap: wrap; gap: var(--s4) var(--s6); align-items: flex-end; justify-content: space-between; margin-bottom: var(--s5); }
.vhead h1 { font-size: 52px; margin: 0; }
.vhead h1 a { text-decoration: none; }
.vhead h1 a:hover { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.vhead__meta { margin: var(--s2) 0 0; color: var(--ink-2); font-size: 17px; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: center; }
.vhead__actions { display: flex; gap: var(--s3); flex-wrap: wrap; }

/* The recording strip: the logo made real. [ play | waveform | time ] */
.rec {
  background: var(--night); color: #F4F2EC;
  display: grid; grid-template-columns: 22px 56px minmax(0, 1fr) auto 22px; gap: var(--s4); align-items: center;
  padding: var(--s4) var(--s4); position: relative;
}
.rec__br { width: 22px; height: 64px; color: var(--teal); }
.rec__br path { fill: currentColor; }
.rec__br--end { transform: scaleX(-1); }
[dir="rtl"] .rec__br--start { transform: scaleX(-1); }
[dir="rtl"] .rec__br--end { transform: none; }
.rec__play {
  width: 52px; height: 52px; border: 2px solid var(--teal); background: transparent; color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.rec__play:hover { background: var(--teal); color: var(--night); }
.rec__play:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.rec__play svg { width: 20px; height: 20px; }
/* play keeps pointing right in Arabic, as on every media control */
.wave {
  height: 64px; display: flex; align-items: center; gap: 2px; cursor: pointer; position: relative;
  touch-action: none; min-width: 0; overflow: hidden;
}
.wave:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.wave i {
  flex: 1 1 0; min-width: 2px; height: calc(var(--h, .1) * 100%);
  background: #5E5C56; transform-origin: center;
  animation: bar-rise .7s var(--ease) both; animation-delay: calc(var(--n) * 6ms);
}
.wave i.on { background: var(--teal); }
[dir="rtl"] .wave { flex-direction: row-reverse; }   /* time runs left to right even in Arabic, like every player */
.rec__time { direction: ltr; unicode-bidi: isolate; font-size: 15px; color: #CFCBC0; min-width: 96px; text-align: end; }
.rec__time b { color: #fff; font-weight: 600; }
.rec__label { position: absolute; inset-inline-start: 98px; top: 6px; font-size: 12px; color: #9A968C; }
.rec__hint { color: #B5B1A6; }
.rec:has(.rec__label) { padding-top: calc(var(--s4) + 10px); }

/* The note, held by the strip's brackets until it is checked */
.note { position: relative; padding: var(--s6) 44px var(--s6); background: var(--sheet); }
.rails { position: absolute; inset: 0; pointer-events: none; }
.rails::before, .rails::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 18px;
  border: 6px solid var(--teal); border-top-width: 0;
  clip-path: inset(0 0 0 0);
  animation: rails-down 1s var(--ease) .3s both;
  transition: clip-path .6s var(--ease), border-color .3s;
}
.rails::before { inset-inline-start: 0; border-inline-end: 0; }
.rails::after { inset-inline-end: 0; border-inline-start: 0; }
.note.is-checked .rails::before, .note.is-checked .rails::after {
  animation: none; clip-path: inset(0 0 100% 0);
}

.note .note__lead { font-size: 21px; line-height: 1.5; max-width: 70ch; margin: 0 0 var(--s6); font-variation-settings: "wdth" 102; }
.note__grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s7); }
.note h2 { font-size: 15px; font-weight: 700; margin: 0 0 var(--s2); color: var(--ink); }
.note section { margin-bottom: var(--s5); }
.note p { margin: 0; }
.note ul.plain { margin: 0; padding: 0; list-style: none; }
.note ul.plain li { padding: 3px 0; }
.note ul.dots { margin: 0; padding-inline-start: 1.1em; }
.note ul.results { margin: 0; padding-inline-start: 1.1em; }
.note ul.results small { color: var(--muted); }
.note .part { border-top: 2px solid var(--ink); padding-top: var(--s5); margin-top: var(--s5); }
.note .part > h2.big { font-size: 24px; font-variation-settings: "wdth" 110; font-weight: 660; margin-bottom: var(--s4); }

.vitals { display: flex; flex-wrap: wrap; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.vitals div { flex: 1 1 112px; background: var(--sheet); padding: var(--s3) var(--s3) var(--s3); }
.vitals dt { font-size: 13px; color: var(--muted); font-weight: 600; }
.vitals dd { margin: 0; white-space: nowrap; font-size: 24px; font-weight: 650; font-variation-settings: "wdth" 108; line-height: 1.15; }
.vitals dd small { font-size: 14px; font-weight: 500; color: var(--muted); margin-inline-start: 3px; }

.dx { list-style: none; margin: 0; padding: 0; }
.dx li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--line-2); }
.dx li:first-child { border-top: 0; }
.dx b { font-weight: 650; font-size: 18px; }
.dx code { font-family: var(--font); font-size: 13px; color: var(--muted); }
.tag {
  font-size: 13px; font-weight: 650; padding: 1px 8px;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
}
.tag--confirmed { background: var(--ink); color: #fff; }
.tag--suspected { background: var(--line-2); color: var(--ink-2); }

.rx { width: 100%; border-collapse: collapse; }
.rx th, .rx td { text-align: start; padding: var(--s3) var(--s3) var(--s3) 0; vertical-align: top; border-top: 1px solid var(--line-2); }
[dir="rtl"] .rx th, [dir="rtl"] .rx td { padding: var(--s3) 0 var(--s3) var(--s3); }
.rx thead th { font-size: 13px; color: var(--muted); font-weight: 600; border-top: 0; padding-top: 0; }
.rx td:first-child { font-weight: 650; }
.rx td small { display: block; color: var(--muted); font-weight: 450; }
.treat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5); margin-top: var(--s5); }

.transcript summary { cursor: pointer; font-weight: 650; font-size: 17px; padding: var(--s2) 0; }
.transcript ol { margin: var(--s3) 0 0; padding: 0; list-style: none; max-width: 75ch; }
.transcript li { padding: var(--s2) 0; border-top: 1px solid var(--line-2); font-size: 16px; }
.transcript li[dir="rtl"] { font-family: var(--font-ar); }

/* Sign-off: the doctor's mark */
.signoff {
  display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); align-items: center; justify-content: space-between;
  margin-top: var(--s6); padding: var(--s5); background: var(--teal-soft);
}
.signoff p { margin: 0; max-width: 60ch; }
.signoff.is-checked { background: var(--checked-soft); color: var(--checked); }
.signoff__mark { display: flex; align-items: center; gap: var(--s3); font-size: 18px; font-weight: 650; }
.signoff__mark svg { width: 34px; height: 34px; flex: none; }
.signoff__mark path { fill: none; stroke: var(--checked); stroke-width: 3; stroke-linecap: square; stroke-dasharray: 40; stroke-dashoffset: 0; }
.signoff.just .signoff__mark path { animation: tick .5s var(--ease) .25s both; }
.signoff__mark small { display: block; font-size: 14px; font-weight: 450; color: var(--ink-2); }

/* Unassigned recording */
.whois { background: var(--verify-soft); padding: var(--s5); margin-bottom: var(--s5); display: grid; gap: var(--s3); }
.whois h2 { margin: 0; font-size: 22px; }
.whois form { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: end; }
.whois label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.whois select { min-height: 44px; min-width: 240px; border: 2px solid var(--ink); background: var(--sheet); padding: 0 var(--s3); }


/* ---------- Motion ---------- */
@keyframes bar-rise { from { transform: scaleY(.04); } to { transform: scaleY(1); } }
@keyframes rails-down { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes spine-draw { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes tick { from { stroke-dashoffset: 40; } to { stroke-dashoffset: 0; } }

.still *, .still *::before, .still *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ======================================================
   Tablet and phone
   ====================================================== */
@media (max-width: 1100px) {
  .plist__cols { display: none; }
  .prow { grid-template-columns: 1fr auto; gap: var(--s2) var(--s4); }
  .prow__name { grid-column: 1; }
  .prow__status { grid-column: 2; grid-row: 1; justify-self: end; }
  .prow__allergy, .prow__none { grid-column: 1 / -1; }
  .prow__last { grid-column: 1; }
  .prow__trace { grid-column: 2; grid-row: 3; justify-self: end; }
  .pgrid { grid-template-columns: minmax(0, 1fr); gap: var(--s6); }
  .note__grid { grid-template-columns: 1fr; gap: 0; }
  .treat-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { padding-bottom: 72px; }
  .topbar__in { height: 54px; padding: 0 var(--s4); }
  .topbar__logo img { height: 24px; }
  .topbar .nav { display: none; }
  .topbar__user { display: none; }   /* sign out lives in the bottom tabs on a phone */
  .tabs {
    display: grid; grid-template-columns: repeat(3, 1fr);
    position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
    background: var(--night); border-top: 2px solid var(--teal);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs a {
    position: relative; display: grid; justify-items: center; gap: 2px; padding: 8px 4px 10px;
    color: #CFCBC0; text-decoration: none; font-size: 12px; font-weight: 600;
  }
  .tabs a svg { width: 22px; height: 22px; }
  .tabs a[aria-current="page"] { color: #fff; }
  .tabs a[aria-current="page"]::before {
    content: ""; position: absolute; top: -13px; left: 50%; width: 44px; height: 22px; margin-left: -22px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 22'%3E%3Cpath d='M0 12h12l5-11 6 19 4-8h17' fill='none' stroke='%2314B8A6' stroke-width='2.4'/%3E%3C/svg%3E") no-repeat center / 44px 22px;
  }
  .tabs a:focus-visible { outline-color: #fff; outline-offset: -4px; }
  .tabs .count { position: absolute; top: 4px; inset-inline-end: calc(50% - 22px); background: var(--verify-line); color: var(--night); font-size: 11px; min-width: 18px; padding: 0 4px; line-height: 18px; text-align: center; font-weight: 700; }

  .page { padding: var(--s4) var(--s4) var(--s6); }
  .list-head h1 { font-size: 34px; }
  .find { grid-template-columns: 20px 1fr 20px; height: 60px; margin-bottom: var(--s5); }
  .find__br { width: 20px; height: 60px; }
  .find input { min-height: 60px; font-size: 20px; padding: 0 var(--s2); }
  .find__key { display: none; }
  .orphans { padding: var(--s3) var(--s4); }
  .orphans a.btn { width: 100%; }
  .prow { padding: var(--s3) var(--s4); }
  .prow__name a { font-size: 18px; }
  .trace { width: 120px; }

  .phead h1 { font-size: 40px; }
  .phead__meta { font-size: 15px; }
  .beat-item { padding-inline-start: 46px; }
  .beat-item__mark { width: 40px; top: 12px; }
  .spine::before { inset-inline-start: 19px; }
  .visit-card { padding: var(--s4); }

  .vhead h1 { font-size: 36px; }
  .vhead__actions { width: 100%; }
  .vhead__actions .btn { flex: 1 1 0; padding: 0 var(--s3); }
  .rec { grid-template-columns: 14px 46px minmax(0, 1fr) auto 14px; gap: 10px; padding: var(--s3); }
  .rec__br { width: 14px; height: 52px; }
  .rec__play { width: 46px; height: 46px; }
  .wave { height: 52px; gap: 1px; }
  .wave i { min-width: 1px; }
  .rec__time { min-width: 0; font-size: 13px; white-space: nowrap; }
  .rec__label { inset-inline-start: 70px; top: 2px; font-size: 11px; }
  .rec:has(.rec__label) { padding-top: 22px; }
  .note { padding: var(--s5) 26px; }
  .rails::before, .rails::after { width: 12px; border-width: 4px; border-top-width: 0; }
  .note .note__lead { font-size: 18px; margin-bottom: var(--s5); }
  .vitals dd { font-size: 24px; }
  .rx thead { display: none; }
  .rx tr { display: grid; padding: var(--s3) 0; border-top: 1px solid var(--line-2); }
  .rx td { border: 0; padding: 0; }
  .signoff { padding: var(--s4); }
  .signoff .btn { width: 100%; }
}

/* ======================================================
   App pages: list columns, forms, settings, admin, link, sign in
   ====================================================== */

/* Patient list: patient, last visit, visits. Allergy, trace and status columns wait for Phase 2 data. */
.plist__cols, .prow { grid-template-columns: minmax(240px, 2fr) minmax(140px, 1fr) 120px; }
.prow__count { font-size: 15px; color: var(--ink-2); justify-self: end; }
.plist__cols span:last-child { justify-self: end; }
.prow__meta span + span::before { content: "·"; margin: 0 .45em; color: var(--muted); }

.orphans--list { align-items: flex-start; }
.orphans__body { flex: 1 1 320px; min-width: 0; }
.orphans--list h2 { margin: 0 0 var(--s2); font-size: 17px; font-weight: 680; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: baseline; }
.orphans__count { font-size: 14px; font-weight: 600; color: var(--verify); }
.orphans__list { list-style: none; margin: 0; padding: 0; }
.orphans__list li { border-top: 1px solid rgba(138, 75, 6, .2); }
.orphans__list a {
  display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr) auto; gap: var(--s4); align-items: baseline;
  padding: var(--s2) 0; text-decoration: none;
}
.orphans__list a:hover .orphans__who { text-decoration: underline; }
.orphans__who { font-weight: 650; }
.orphans__what { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orphans__list time { font-size: 14px; color: var(--muted); white-space: nowrap; }

/* Notices */
.notice { margin: 0 0 var(--s5); padding: var(--s3) var(--s4); font-size: 15px; background: var(--sheet); border: 1px solid var(--line); }
.notice--info { color: var(--ink-2); }
.notice--danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); font-weight: 600; }
.notice--verify { background: var(--verify-soft); color: var(--verify); border-color: var(--verify-line); font-weight: 600; }
.muted { color: var(--muted); }
.status--processing { color: var(--ink-2); }
.status--failed { color: var(--danger); }

/* Form pages */
.fhead { margin-bottom: var(--s5); }
.fhead h1 { font-size: 44px; margin: 0; }
.fhead p { margin: var(--s2) 0 0; color: var(--ink-2); }
.sheet { background: var(--sheet); border: 1px solid var(--line); padding: var(--s5); margin: 0 0 var(--s5); }
.sheet--narrow { max-width: 620px; }
.sheet--flush { padding: 0; }
fieldset.sheet { min-width: 0; }
.sheet > legend { float: left; width: 100%; padding: 0; margin: 0 0 var(--s4); font-size: 19px; font-weight: 680; }
.sheet > legend + * { clear: both; }
.sheet > h2 { margin: 0 0 var(--s4); font-size: 19px; font-weight: 680; }
.sheet > p { margin: 0 0 var(--s4); max-width: 62ch; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s4); }
.form-grid--lists { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.form-grid + .form-grid, .form-grid + .rowset, .rowset + .rowset { margin-top: var(--s4); }
.field { display: grid; gap: 6px; align-content: start; }
.field__label { font-size: 14px; font-weight: 650; color: var(--ink); }
.field__label small { font-weight: 450; color: var(--muted); margin-inline-start: 4px; }
.field input, .field select, .field textarea, .inline-form input {
  width: 100%; min-height: 44px; padding: var(--s2) var(--s3);
  border: 2px solid var(--ink); border-radius: 0; background: var(--sheet);
}
.field textarea { min-height: 112px; resize: vertical; line-height: 1.45; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .inline-form input:focus-visible { outline-offset: 0; }
.check { display: flex; gap: var(--s2); align-items: center; margin: 0 0 var(--s4); font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.rowset { display: grid; gap: var(--s3); align-items: end; padding-top: var(--s3); border-top: 1px solid var(--line-2); }
.rowset--med { grid-template-columns: 28px repeat(4, minmax(0, 1fr)); }
.rowset--dx { grid-template-columns: 28px minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
.rowset--result { grid-template-columns: 28px minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2fr); }
.rowset__n { align-self: center; font-weight: 650; color: var(--muted); padding-top: 22px; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: flex-end; align-items: center; margin-top: var(--s5); }
.form .notice { margin-bottom: var(--s4); }

/* Settings */
.settings { display: grid; gap: var(--s5); }
.settings__more { display: none; max-width: 620px; }
.settings__more a { display: block; padding: var(--s3) 0; border-top: 1px solid var(--line); font-weight: 620; text-decoration: none; }
.settings__more a::after { content: " \2192"; }
[dir="rtl"] .settings__more a::after { content: " \2190"; }

/* Admin */
.ascroll { overflow-x: auto; }
.ascroll:focus-visible { outline-offset: -3px; }
.atable { width: 100%; border-collapse: collapse; font-size: 15px; }
.atable th, .atable td { text-align: start; padding: var(--s3) var(--s4); border-top: 1px solid var(--line-2); vertical-align: middle; }
.atable thead th { font-size: 13px; color: var(--muted); font-weight: 600; border-top: 0; white-space: nowrap; }
.atable tbody tr:first-child td { border-top: 2px solid var(--ink); }
.atable .num { text-align: end; }
.atable__name { font-weight: 650; }
.atable__actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.atable__actions form { margin: 0; }
.inline-form { display: flex; gap: var(--s2); align-items: center; }
.inline-form input { width: 160px; min-height: 36px; padding: 4px var(--s2); font-size: 14px; }
.btn--sm { min-height: 36px; font-size: 14px; }
.chip { display: inline-block; font-size: 13px; font-weight: 650; padding: 1px 8px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip--on { background: var(--ink); color: #fff; }

/* Telegram link */
.linkbox__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.linkbox__head h2 { margin: 0; font-size: 19px; font-weight: 680; }
.linkbox p { margin: 0 0 var(--s4); }
.qr { width: 200px; max-width: 100%; margin: 0 0 var(--s4); padding: var(--s3); background: #fff; border: 2px solid var(--ink); }
.qr svg { display: block; width: 100%; height: auto; }
.code-box code {
  display: inline-block; direction: ltr; unicode-bidi: isolate; font-size: 22px; font-weight: 650;
  padding: var(--s3) var(--s4); background: var(--paper); border: 2px solid var(--ink); user-select: all;
}

/* Sign in and signed out: the night page, the form held in brackets */
body.night { background: var(--night); color: #F4F2EC; }
body.night .page { padding-top: var(--s8); }
.gate { display: grid; justify-items: center; gap: var(--s5); }
.gate__form {
  position: relative; width: 100%; max-width: 420px; display: grid; gap: var(--s4);
  background: var(--sheet); color: var(--ink); padding: var(--s6) 52px;
}
.gate__form h1 { margin: 0; font-size: 32px; font-variation-settings: "wdth" 110; font-weight: 680; }
.gate__form p { margin: 0; }
.gate__form .notice { margin: 0; }
.gate__form .btn { width: 100%; margin-top: var(--s2); }
.gate__br { position: absolute; top: 0; bottom: 0; width: 22px; height: 100%; color: var(--teal); }
.gate__br path { fill: currentColor; }
.gate__br--start { inset-inline-start: 0; }
.gate__br--end { inset-inline-end: 0; transform: scaleX(-1); }
[dir="rtl"] .gate__br--start { transform: scaleX(-1); }
[dir="rtl"] .gate__br--end { transform: none; }
.gate__line { margin: 0; color: #CFCBC0; font-size: 17px; text-align: center; }

/* Top bar and phone tabs: log out is a form button that looks like the links */
.topbar__user form, .tabs form { margin: 0; }
.topbar__out {
  background: none; border: 0; padding: 0; cursor: pointer; color: #CFCBC0;
  text-decoration: underline; text-underline-offset: 3px; font-size: 14px;
}
.topbar__out:hover { color: #fff; }
.topbar__out:focus-visible { outline-color: #fff; }
.tabs form { display: contents; }
.tabs button {
  position: relative; display: grid; justify-items: center; gap: 2px; padding: 8px 4px 10px; width: 100%;
  background: none; border: 0; cursor: pointer; color: #CFCBC0; font-size: 12px; font-weight: 600;
}
.tabs button svg { width: 22px; height: 22px; }
.tabs button:focus-visible { outline-color: #fff; outline-offset: -4px; }

/* Visit page extras */
.transcript__lines { margin: var(--s3) 0 0; max-width: 75ch; }
.transcript__lines p { padding: var(--s2) 0; border-top: 1px solid var(--line-2); }
.transcript__lines p:lang(ar) { font-family: var(--font-ar); }
.rx-scroll { overflow-x: auto; }
.player { display: block; width: 100%; margin: 0 0 var(--s4); }
.whois__suggest { display: grid; gap: var(--s3); padding-bottom: var(--s4); border-bottom: 1px solid rgba(138, 75, 6, .25); }
.whois__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.whois__list li { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: center; background: var(--sheet); padding: var(--s3) var(--s4); }
.whois__list li b, .whois__list li strong { font-weight: 650; font-size: 17px; }
.whois__meta { color: var(--muted); font-size: 14px; flex: 1 1 auto; }
.whois__meta span + span::before { content: "·"; margin: 0 .45em; }
.whois__list form { margin-inline-start: auto; }
.whois__or { align-self: center; padding-bottom: 10px; color: var(--muted); font-weight: 600; }
.whois input[type="text"], .whois input:not([type]) { min-height: 44px; min-width: 220px; border: 2px solid var(--ink); background: var(--sheet); padding: 0 var(--s3); }
.whois p { margin: 0; }
.signoff__draft { color: var(--teal-deep); font-weight: 550; }
.note--plain { margin-top: var(--s5); }
.panel--follow { background: var(--ink); color: #fff; border-color: var(--ink); }
.panel--follow h2 { color: #fff; }
.panel--follow p { margin: 0; }
.vscroll { overflow-x: auto; max-width: 100%; }
.vscroll:focus-visible { outline-offset: -3px; }
.phead .btn svg, .vhead__actions .btn svg { width: 16px; height: 16px; }

@media (max-width: 1100px) {
  .plist__cols { display: none; }
  .prow { grid-template-columns: 1fr auto; }
  .prow__last { grid-column: 1; }
  .prow__count { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .rowset--med, .rowset--dx, .rowset--result { grid-template-columns: 28px repeat(2, minmax(0, 1fr)); }
  .rowset--med .rowset__n, .rowset--dx .rowset__n, .rowset--result .rowset__n { grid-row: span 2; }
}

@media (max-width: 640px) {
  .fhead h1 { font-size: 34px; }
  .sheet { padding: var(--s4); }
  .sheet--flush { padding: 0; }
  .form-actions .btn { flex: 1 1 0; }
  .rowset--med, .rowset--dx, .rowset--result { grid-template-columns: 1fr; }
  .rowset__n { padding-top: 0; }
  .rowset--med .rowset__n, .rowset--dx .rowset__n, .rowset--result .rowset__n { grid-row: auto; }
  .settings__more { display: block; }
  .orphans__list a { grid-template-columns: 1fr auto; gap: 2px var(--s3); }
  .orphans__what { grid-column: 1 / -1; grid-row: 2; }
  .whois__list form, .whois__list .btn { width: 100%; margin-inline-start: 0; }
  .whois form { display: grid; }
  .whois select, .whois input[type="text"], .whois input:not([type]) { min-width: 0; width: 100%; }
  .whois__or { padding: 0; }
  /* the admin table becomes one card per user */
  .atable thead { display: none; }
  .atable, .atable tbody, .atable tr, .atable td { display: block; }
  .atable tr { padding: var(--s3) var(--s4); border-top: 2px solid var(--ink); }
  .atable tbody tr:first-child td { border-top: 0; }
  .atable td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s3); text-align: start; }
  .atable td::before { content: attr(data-label); font-size: 13px; color: var(--muted); font-weight: 600; }
  .atable .num { text-align: start; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input { width: 100%; }
  body.night { padding-bottom: 0; }
  body.night .page { padding-top: var(--s6); }
  .gate__form { padding: var(--s5) 36px; }
  .gate__br { width: 16px; }
}

/* rows hidden by search must stay hidden even when a component sets display */
[hidden] { display: none !important; }

/* Plan and usage */
.usage-meter { inline-size: 100%; block-size: 14px; margin-block: var(--s3); }
.plans { border: 0; padding: 0; margin: 0 0 var(--s3); display: grid; gap: var(--s2); }
.plan-option { display: flex; gap: var(--s2); align-items: baseline; }
