/*
 * Daftar — the whole stylesheet.
 *
 * There is no CSS framework here on purpose. Bootstrap's RTL build was doing
 * three things for us (a grid, form controls, utilities) at the cost of a CDN
 * request on every page load, and an Egyptian clinic on a bad connection would
 * see an unstyled screen while it resolved. Everything below is about 600 lines
 * and ships with the app.
 *
 * Two rules run through all of it:
 *
 *   1. Logical properties only. `margin-inline-start`, never `margin-left`.
 *      A physical property is a bug that only appears in the Arabic UI, and it
 *      gets found in a screenshot from a clinic rather than in review.
 *
 *   2. Western digits, tabular. Reception reads 2,500 — not ٢٥٠٠ — and columns
 *      of money only line up with `tabular-nums`.
 */

/* ── Fonts ──────────────────────────────────────────────────────────────────
   Self-hosted. Tajawal from Google Fonts would be one more thing to fail on a
   clinic's connection, and the fallback (Tahoma) has visibly different metrics.
   `font-display: swap` still applies for the first paint before the local file
   is read from cache. ~130KB for the whole set. */

@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/tajawal-arabic-400.d595af28c13f.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/tajawal-latin-400.f18eb7346bae.woff2") format("woff2");
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/tajawal-arabic-500.899cfbe65444.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/tajawal-latin-500.7256be463352.woff2") format("woff2");
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/tajawal-arabic-700.10367de774c9.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/tajawal-latin-700.e9c38c1110be.woff2") format("woff2");
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("../fonts/tajawal-arabic-800.93993923a466.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Tajawal";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("../fonts/tajawal-latin-800.316fa1995ea5.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/plex-mono-latin-400.79936b18df9f.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/plex-mono-latin-500.b1c8a895f5fd.woff2") format("woff2");
}

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  --paper: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --sand: #efeae1;
  --ink: #211e1a;
  --ink-2: #4e4740;
  --muted: #8a8177;
  --faint: #a79d91;
  --line: #e3dcd1;
  --line-2: #d4cabb;
  --line-3: #ede7de;

  --green: #176b5b;
  --green-d: #0f5348;
  --green-soft: #e2efea;
  --green-tint: #e9f3ef;
  --green-line: #b9d8cd;

  --amber: #a9701a;
  --amber-ink: #8a5a14;
  --amber-soft: #f6ecd9;
  --amber-tint: #fbf5e9;
  --amber-line: #e4d2af;

  --blue: #2c5f86;
  --blue-tint: #e4edf5;
  --blue-line: #b7cde0;

  --red: #a8402c;
  --red-ink: #8c3524;
  --red-soft: #f7e6e0;
  --red-tint: #faebe6;
  --red-line: #e2bfb4;

  --radius: 12px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(33, 30, 26, 0.05);
  --shadow-2: 0 8px 24px -12px rgba(33, 30, 26, 0.18);

  /* Keep in sync with PX_PER_MINUTE in scheduling/timeline.py. */
  --px-per-minute: 1.2;

  --font: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  /* Tajawal is named before any generic monospace on purpose: Plex Mono has no
     Arabic glyphs, and a generic `monospace` fallback breaks Arabic letter
     joining — "يناير" renders as "ينا ير". */
  --font-num: "Plex Mono", "Tajawal", "Segoe UI", Tahoma, sans-serif;
}

/* ── Base ───────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h1 { font-size: 21px; font-weight: 800; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14.5px; font-weight: 700; }

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-d); }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Any LTR run inside Arabic — phone numbers, emails — needs isolating.
   `dir="ltr"` alone still lets neighbouring characters reorder across the
   boundary, which turns +20 100… into something nobody can dial. */
[dir="ltr"] { unicode-bidi: isolate; }

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

.muted { color: var(--muted); }
.grow { flex-grow: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }
.nowrap { white-space: nowrap; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── App chrome ─────────────────────────────────────────────────────────── */

.app-bar {
  height: 60px;
  background: var(--surface);
  border-block-end: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 28px;
  padding-inline: 24px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--green);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.brand-name {
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.nav { display: flex; align-items: center; gap: 22px; }
.navlink {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  padding-block: 6px;
}
.navlink:hover { color: var(--ink); }
.navlink[aria-current="page"] {
  color: var(--green);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--green);
}

.avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--sand);
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13.5px;
  flex: none;
}

.page {
  padding-inline: 24px;
  padding-block: 22px 40px;
}

/* ── Cards, toolbar ─────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-pad { padding: 16px 20px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-block-end: 18px;
}
.toolbar h1 { line-height: 1.2; }
.toolbar .sub { font-size: 12.5px; color: var(--muted); }
.divider { width: 1px; height: 34px; background: var(--line); }

.crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--muted);
  margin-block-end: 12px;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding-inline: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  background: none;
}
.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 2px rgba(23, 107, 91, 0.28);
}
.btn-primary:hover { background: var(--green-d); color: #fff; }
.btn-quiet {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-2);
  font-weight: 500;
}
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
/* Outlined rather than filled red. There is one of these in the product --
   revoking a colleague's access -- and a solid red block on the page pulls the
   eye to the destructive action every time the screen is opened for any other
   reason. */
.btn-danger {
  background: var(--surface);
  color: var(--red-ink);
  border-color: var(--red-line);
  font-weight: 700;
}
.btn-danger:hover { background: var(--red-tint); color: var(--red-ink); }
.btn-sm { height: 32px; padding-inline: 12px; font-size: 13px; }
.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: 9px;
  border-color: var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
}
.btn-link {
  height: auto; padding: 0;
  background: none; border: none;
  color: var(--green); font-weight: 700; font-size: 13.5px;
}

/* Status actions on an appointment. Outlined, so no single one shouts. */
.btn-act {
  height: 28px;
  padding-inline: 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
}
.btn-act:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-act-go { color: var(--green); border-color: var(--green-line); }
.btn-act-no { color: var(--red-ink); border-color: var(--red-line); }

/* ── Chips ──────────────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding-inline: 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--sand);
  color: var(--ink-2);
}
.chip .dot { width: 6px; height: 6px; border-radius: 999px; flex: none; }

/* Status colours. The class names are the Appointment.Status values, so a
   template writes `chip--{{ appointment.status }}` and nothing has to be
   mapped in Python. A colour never carries the meaning alone — every chip
   also says the word, because clinic lighting is not a design environment. */
.chip--booked { background: var(--amber-soft); color: var(--amber-ink); }
.chip--booked .dot { background: var(--amber); }
.chip--confirmed { background: var(--green-soft); color: var(--green); }
.chip--confirmed .dot { background: var(--green); }
.chip--arrived { background: var(--blue-tint); color: var(--blue); }
.chip--arrived .dot { background: var(--blue); }
.chip--completed { background: var(--sand); color: var(--muted); }
.chip--completed .dot { background: var(--muted); }
.chip--no_show { background: var(--red-soft); color: var(--red-ink); }
.chip--no_show .dot { background: var(--red); }
.chip--cancelled { background: var(--sand); color: var(--faint); }
.chip--cancelled .dot { background: var(--faint); }

/* ── Timeline ───────────────────────────────────────────────────────────── */

.tl { display: flex; flex-direction: column; overflow: hidden; }

.tl-head {
  height: 52px;
  flex: none;
  display: flex;
  border-block-end: 1px solid var(--line);
  background: var(--surface-2);
}
.tl-head .spacer { width: 62px; flex: none; }
.tl-room {
  flex-grow: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline-start: 14px;
  border-inline-start: 1px solid var(--line-3);
  min-width: 0;
}
.tl-room .name { font-size: 14.5px; font-weight: 700; line-height: 1.2; }
.tl-room .who { font-size: 12px; color: var(--muted); }
.tl-room .pip { width: 8px; height: 8px; border-radius: 999px; background: var(--green); flex: none; }

.tl-body {
  position: relative;
  display: flex;
  overflow-y: auto;
  /* Room for the first hour label to sit on its line instead of being clipped
     by the header above it. */
  padding-block-start: 14px;
}

.tl-rules { position: absolute; inset-block-start: 14px; inset-inline: 0; inset-block-end: 0; pointer-events: none; }
.tl-rule { position: absolute; inset-inline: 0; border-block-start: 1px solid var(--line-3); }
.tl-rule--half { border-block-start-style: dashed; border-block-start-color: #f1ece4; }

.tl-gutter { width: 62px; flex: none; position: relative; }
.tl-hour {
  position: absolute;
  inset-inline-end: 10px;
  transform: translateY(-50%);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--muted);
}

.tl-col {
  flex-grow: 1;
  position: relative;
  border-inline-start: 1px solid var(--line-3);
  min-width: 0;
}

.tl-now {
  position: absolute;
  inset-inline: 0;
  height: 0;
  display: flex;
  align-items: center;
  pointer-events: none;
  z-index: 3;
}
.tl-now .label {
  width: 62px; flex: none;
  text-align: center;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: #fff;
  background: var(--red);
  border-radius: 999px;
}
.tl-now .line { flex-grow: 1; height: 1.5px; background: var(--red); }

/* One appointment. */
.appt {
  position: absolute;
  inset-inline: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  padding: 6px 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: var(--shadow-1);
  color: var(--ink);
  z-index: 1;
}
.appt:hover { z-index: 2; border-color: var(--ink-2); }
.appt .at {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 500;
}
.appt .who { font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.appt .meta { font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.appt .acts { display: flex; gap: 5px; flex-wrap: wrap; margin-block-start: 4px; }
.appt--compact { justify-content: center; padding-block: 2px; }
.appt--compact .who { font-size: 12.5px; }

.appt--booked { background: var(--amber-tint); border-color: var(--amber-line); }
.appt--booked .at { color: var(--amber-ink); }
.appt--confirmed { background: var(--green-tint); border-color: var(--green-line); }
.appt--confirmed .at { color: var(--green); }
.appt--arrived { background: var(--blue-tint); border-color: var(--blue-line); }
.appt--arrived .at { color: var(--blue); }
.appt--completed { background: #f4f2ee; border-color: #dfd8cc; }
.appt--completed .at,
.appt--completed .who,
.appt--completed .meta { color: var(--muted); }
.appt--no_show { background: var(--red-tint); border-color: var(--red-line); }
.appt--no_show .at,
.appt--no_show .who { color: var(--red-ink); }
.appt--cancelled { background: #f4f2ee; border-color: #dfd8cc; opacity: 0.55; }
.appt--cancelled .who { text-decoration: line-through; }

/* The stripe marking a medical alert sits on the leading edge, so it follows
   the reading direction. A box-shadow would not. */
.appt--alert {
  border-inline-start-width: 3px;
  border-inline-start-color: var(--red);
}
.alert-mark { color: var(--red); flex: none; }

/* A bookable stretch, drawn rather than left blank: this is what turns the
   grid from a list into something you can find a free hour in. */
.tl-gap {
  position: absolute;
  inset-inline: 6px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--faint);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  padding-inline: 8px;
}
.tl-gap:hover { border-color: var(--green); color: var(--green); background: #fbfdfc; }

/* ── Rail ───────────────────────────────────────────────────────────────── */

.with-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  gap: 20px;
  align-items: start;
}
.rail { display: flex; flex-direction: column; gap: 14px; }

/* ── Split ──────────────────────────────────────────────────────────────────
   Two panels of equal weight. Distinct from .with-rail above, which is a wide
   main column plus a narrow sidebar: here neither half is subordinate to the
   other, so neither gets the leftover width. */

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.split > * { min-width: 0; }
/* The 620px measure is for a page-wide column of fields. Inside a half it is
   never the binding constraint, and leaving it on makes the card stop short of
   its own column on a wide screen. */
.split .form-card { max-width: none; }

/* Both halves end on the same line. Only worth asking for where the two are
   genuinely a pair -- clinic details beside working days -- and only where the
   shorter card has something to put in the space, since stretching buys the
   even bottom edge with empty card above it. */
.split--even { align-items: stretch; }
.split--even > .form-card { display: flex; flex-direction: column; }
.split--even > .form-card > :last-child { margin-block-end: 0; }

/* Below this a half is narrower than the working-days table, and .table-wrap
   would quietly turn it back into a horizontal scroller with the closing time
   clipped off the end. Stack instead. */
@media (max-width: 1120px) {
  .split { grid-template-columns: 1fr; }
}

.stat .label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.stat .value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.stat .unit { font-size: 15px; font-weight: 500; color: var(--muted); }

.meter { display: flex; gap: 3px; height: 6px; border-radius: 999px; overflow: hidden; margin-block-start: 12px; }
.meter span { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-block-start: 9px; font-size: 12px; color: var(--muted); }
.legend .dot { width: 6px; height: 6px; border-radius: 999px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
table.data {
  width: 100%;
  /* The floor exists for the wide reports -- the patient list, the daily close
     -- where squeezing eight columns into a phone makes all of them
     unreadable. It is wrong for a short table: the working-days grid is four
     narrow columns and inheriting 640px turned it into a sideways scroller
     inside a card with empty screen either side of it. */
  min-width: 640px;
  border-collapse: collapse;
}
table.data--fit { min-width: 0; }
table.data th {
  text-align: start;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 12px 16px;
  background: var(--surface-2);
  border-block-end: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 13px 16px;
  border-block-start: 1px solid var(--line-3);
  vertical-align: middle;
}
table.data tbody tr:first-child td { border-block-start: none; }
table.data tbody tr:hover { background: #fdfcfa; }
td.num, th.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
/* A column whose heading and values line up on their shared centre. Needed
   where the value is an LTR run (an email) in an RTL table: start-aligned, the
   heading and the address end up at opposite ends of a wide column and stop
   looking related. */
/* Qualified with table.data so it outranks `table.data th { text-align: start }`
   -- unqualified, the heading stayed start-aligned while the value centred,
   which looks more broken than leaving both alone. */
table.data th.mid,
table.data td.mid { text-align: center; }
.empty { padding: 22px 16px; color: var(--muted); font-size: 14px; text-align: center; }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  max-width: 620px;
}
/* 620px is a comfortable measure for a column of labelled fields and too
   narrow for a form built around a table: `table.data` has a 640px floor, so
   the last column lands outside the card and .table-wrap quietly turns it into
   a horizontal scroller. The working-days card is the one that needs this. */
.form-card--wide { max-width: 780px; }
.field { margin-block-end: 16px; }
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin-block-end: 6px;
}
/* Everything except the controls that are not boxes.
   This was a whitelist of input types once, and it silently missed
   type="search" — the patient search rendered as a bare browser input at
   about a fifth of its width. A whitelist of HTML input types is a list you
   will forget to update; the exclusion list is the short, stable one. */
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.field .help { font-size: 12.5px; color: var(--muted); margin-block-start: 6px; line-height: 1.5; }
/* Django's password validators hand over their help as an <ul>, which is the
   one place a bullet list appears inside a form. Left alone it inherits the
   browser's 40px indent and hangs off the edge of the field. */
.field .help ul { margin: 4px 0 0; padding-inline-start: 18px; }
.field .help li { margin-block-end: 2px; }
.field .err { font-size: 13px; color: var(--red-ink); font-weight: 500; margin-block-start: 6px; }
.field--check { display: flex; align-items: center; gap: 10px; }
.field--check > label { margin: 0; font-weight: 500; font-size: 14.5px; color: var(--ink); }
.field--check input { width: 20px; height: 20px; accent-color: var(--green); }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}

/* Controls that live in a table row rather than in a .field.
   The working-days table is seven rows of three controls and the staff list is
   one picker per person; at the 46px height a .field control gets, either one
   becomes a page of boxes with the information lost between them. */
table.data select,
table.data input[type="time"],
select.compact {
  min-height: 36px;
  /* A time input renders its own AM/PM control and clock button on top of the
     value. Without a floor it collapses to the column width and shows "PM"
     with the hours clipped off, which reads as an empty field. */
  min-width: 124px;
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}
table.data select:focus,
table.data input[type="time"]:focus,
select.compact:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
table.data input[type="checkbox"] {
  width: 19px;
  height: 19px;
  accent-color: var(--green);
}

/* ── Lookup ─────────────────────────────────────────────────────────────────
   The search box that stands in for a select with thousands of rows. It has to
   look like every other field until it is typed into, or reception will not
   know it is the same kind of thing. */

.lookup { position: relative; }
.lookup-input { width: 100%; }

.lookup-list {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 20;
  max-height: 268px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
}
/* Nothing to show means nothing on screen, including no border. An empty
   bordered box reads as "no results" when in fact nothing was asked. */
.lookup-list:empty { display: none; }

.lookup-option {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 10px 13px;
  border: none;
  background: none;
  font: inherit;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}
.lookup-option + .lookup-option { border-block-start: 1px solid var(--line-3); }
.lookup-option:hover,
.lookup-option.is-active { background: var(--green-tint); }
.lookup-option .who { font-weight: 700; }
.lookup-option .meta {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--muted);
  /* An LTR run -- a phone number or a date -- inside an RTL row. */
  unicode-bidi: isolate;
}
.lookup-empty { padding: 12px 13px; color: var(--muted); font-size: 13.5px; }

/* htmx toggles this class for the duration of the request. A spinner would be
   too much for a query that answers in milliseconds; a dimmed dot is enough to
   say the box is working. */
.lookup-busy {
  position: absolute;
  inset-inline-end: 12px;
  top: 38px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  opacity: 0;
  transition: opacity 120ms linear;
}
.lookup-busy.htmx-request { opacity: 0.65; }

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-block-start: 6px;
}

/* ── Search ─────────────────────────────────────────────────────────────────
   Search is the patient screen, not a filter on it, so the field is sized like
   the main thing on the page rather than a toolbar afterthought. */

.search {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding-inline: 16px;
  gap: 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.search .glass { color: var(--muted); flex: none; }
.search:focus-within .glass { color: var(--green); }

.search input[type="search"] {
  flex-grow: 1;
  height: 54px;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  min-width: 0;
}
.search input[type="search"]:focus { outline: none; box-shadow: none; }
.search input[type="search"]::placeholder { color: var(--faint); }
/* WebKit draws its own clear button which sits on the wrong side in RTL and
   ignores the type scale; the one below is ours. */
.search input[type="search"]::-webkit-search-cancel-button { appearance: none; }

.search .hint {
  flex: none;
  font-family: var(--font-num);
  font-size: 12.5px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 8px;
}
.search:focus-within .hint { visibility: hidden; }

.search .clear {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 999px;
  border: none;
  background: var(--sand);
  color: var(--ink-2);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.search .clear:hover { background: var(--line); color: var(--ink); }
.search[data-filled="true"] .clear { display: inline-flex; }
.search[data-filled="true"] .hint { display: none; }

.search-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-block-start: 10px;
  font-size: 13.5px;
  color: var(--muted);
  min-height: 22px;
}
/* htmx marks the element it is about to swap; a search that looks frozen for
   300ms reads as broken, so say something is happening. */
.search-meta .working { display: none; }
.htmx-request .search-meta .working,
.search-meta.htmx-request .working { display: inline; }

/* Suggested free times, offered instead of a blank time field. */
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot {
  height: 36px;
  padding-inline: 13px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.slot:hover { border-color: var(--green); color: var(--green); }
.slot[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }

/* ── Notices ────────────────────────────────────────────────────────────── */

.notice {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 14px;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-block-end: 14px;
  border: 1px solid;
}
.notice svg { flex: none; margin-block-start: 2px; }
.notice-info { background: var(--green-soft); border-color: var(--green-line); color: var(--green-d); }
.notice-success { background: var(--green-soft); border-color: var(--green-line); color: var(--green-d); }
.notice-warning { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber-ink); }
.notice-error,
.notice-danger { background: var(--red-soft); border-color: var(--red-line); color: var(--red-ink); }

.alert-banner {
  background: var(--red-tint);
  border: 1px solid var(--red-line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 11px;
}
.alert-banner .k { font-size: 12.5px; font-weight: 700; color: var(--red-ink); }
.alert-banner .v { font-size: 15px; font-weight: 700; color: #7a2e1f; line-height: 1.45; }

/* ── Patient record timeline ────────────────────────────────────────────── */

.visit { display: grid; grid-template-columns: 96px 22px minmax(0, 1fr); }
.visit .when { padding-block: 4px 18px; }
.visit .when .d { font-size: 13.5px; font-weight: 500; }
.visit .when .t { font-size: 12px; color: var(--muted); }
.visit .rail-line { position: relative; display: flex; justify-content: center; }
.visit .rail-line::before {
  content: "";
  position: absolute;
  inset-block: 0;
  width: 2px;
  background: var(--line-3);
}
.visit .node {
  width: 11px; height: 11px;
  border-radius: 999px;
  margin-block-start: 6px;
  position: relative;
  border: 2px solid var(--surface);
  background: var(--muted);
}
.visit .body { padding-inline-start: 16px; padding-block: 2px 18px; }

/* ── Sign in ────────────────────────────────────────────────────────────── */

.signin { display: grid; grid-template-columns: 620px minmax(0, 1fr); min-height: 100vh; }
.signin-form {
  background: var(--surface);
  padding: 40px 68px;
  display: flex;
  flex-direction: column;
}
.signin-form .mid { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; gap: 26px; padding-block: 40px; }
.signin-form h1 { font-size: 30px; letter-spacing: -0.025em; line-height: 1.25; }
.signin-brand {
  background: #14322c;
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
}
.signin-brand h2 { font-size: 32px; font-weight: 800; line-height: 1.35; color: #fff; max-width: 460px; }
.signin-brand p { font-size: 16.5px; color: #a8c9be; line-height: 1.7; margin: 14px 0 0; max-width: 460px; }
.signin-brand svg { position: absolute; inset-block-start: 0; inset-inline-end: 0; opacity: 0.5; }

/* ── Narrower screens ───────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .with-rail { grid-template-columns: minmax(0, 1fr); }
  .rail { flex-direction: row; flex-wrap: wrap; }
  .rail > * { flex: 1 1 260px; }
}

@media (max-width: 760px) {
  .app-bar { gap: 14px; padding-inline: 14px; overflow-x: auto; }
  .page { padding-inline: 14px; }
  .signin { grid-template-columns: minmax(0, 1fr); }
  .signin-brand { display: none; }
  .signin-form { padding: 28px 22px; }
  .tl-body { overflow-x: auto; }
}

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