/* Interlude portal: the signed-in staff pages only. Loaded by base.html after app.css; patient pages
   (patient_base.html and everything that extends it, incl. the page inside the iPhone app) never load it, so nothing
   here can change what patients see. Uses app.css's custom properties (--night, --gold, --page, --surface, --ink …).

   Each part of the portal redesign owns one numbered section below. Keep edits inside your own section so the
   branches merge cleanly. */


/* ===== 1. Brand frame: tokens, dusk header, navigation & clinic menu, page header, footer, buttons ===== */
/* Every staff page opens with a compact band of the business page's Sonoran dusk (base.html): the night sky, a few
   stars, the banded sun setting between mesas, saguaros, and a dune in the page's own color, so the desert floor
   becomes the page. The data below sits on light sand and white cards. Pages that bring their own desert scene
   (sign-in, two-factor, sign-up) have body class "portal-auth", not "portal": nothing in this section but the skip
   link and the clinic menu reaches them.

   Inside the band the color tokens are the night sky's (white ink, raised dark surfaces, gold actions), so anything a
   page puts in its header (buttons, chips, avatars, links, the ⓘ) reads on the sky without its own rules. Menus and
   pop-ups that open from the band get the page's own colors back (the --paper-* copies). Text only ever sits on the
   dark part of the sky; the warm horizon only sits behind the artwork. */

.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 40; padding: 0.7rem 1.1rem; border-radius: 999px;
  background: var(--gold); color: #1d1838; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 0.6rem; }

body.portal {
  --on-sky: #ffffff; --on-sky-2: #e2daee; --on-sky-3: #c9c0da; --sun-ink: #f6c27a;
  --bar-h: 52px;               /* the band's top row */
  --art-h: 80px;               /* the horizon artwork along the band's bottom edge (band.svg: 1 unit = 0.8px) */
  --art-pad: 34px;             /* below the page title's last line: the sun and mesas stay under it, only dark saguaros reach higher */
  --col: calc(1320px - 4rem);  /* the page column the title lines up with (main.page) */
  --paper-scheme: light;
  /* The page's own colors, for menus and pop-ups that open from inside the band. */
  --paper-ink: var(--ink); --paper-ink-2: var(--ink-2); --paper-muted: var(--muted); --paper-surface: var(--surface);
  --paper-surface-2: var(--surface-2); --paper-line: var(--line); --paper-line-2: var(--line-2);
  --paper-field: var(--field); --paper-accent: var(--accent); --paper-accent-hover: var(--accent-hover);
  --paper-on-accent: var(--on-accent); --paper-accent-ink: var(--accent-ink); --paper-accent-tint: var(--accent-tint);
  --paper-focus: var(--focus); --paper-red: var(--red); --paper-red-tint: var(--red-tint);
  --paper-green-ink: var(--green-ink); --paper-green-tint: var(--green-tint); --paper-amber-ink: var(--amber-ink);
  --paper-amber-tint: var(--amber-tint); --paper-navy-tint: var(--navy-tint); --paper-dusk-ink: var(--dusk-ink);
}
body.portal:has(main.wide) { --col: calc(1480px - 4rem); }
body.portal:has(main.narrow) { --col: 696px; }
body.portal:has(main.brief-page) { --col: calc(1000px - 4rem); }
@media (prefers-color-scheme: dark) {
  body.portal { --paper-scheme: dark; }
  /* Dark pages: the night sky's gold for the main action, as on the business page's dusk. (Light pages keep the soft
     clay: pale gold on white cards is too faint for the button that matters.) */
  body.portal .btn.primary { --accent: #ffd98f; --accent-hover: #ffe5b0; --on-accent: #1d1838; }
}

@media screen {
  /* --- The band ------------------------------------------------------------------------------------------------ */
  body.portal .dusk { position: relative; z-index: 3; isolation: isolate; color: var(--on-sky);
    background: linear-gradient(to top, #b45d50 0, #8f4655 14px, #6c385a 28px, #4f2d5a 44px, #3c2757 64px, #2d2150 90px,
      #221a41 124px, #191430 160px); }
  /* Sky colors inside the band (see the top of this section). */
  body.portal .dusk > :is(.topbar, .hero, .pagehead) {
    color-scheme: dark; --focus: var(--gold);
    --ink: #ffffff; --ink-2: var(--on-sky-2); --muted: var(--on-sky-3);
    --surface: #2a2244; --surface-2: #362c57; --line: #463c68; --line-2: #605581; --field: #8d83aa;
    --accent: #ffd98f; --accent-hover: #ffe5b0; --on-accent: #1d1838; --accent-ink: #ffd2a8;
    --accent-tint: rgba(255, 217, 143, 0.14);
    --red: #ff9a9a; --red-tint: rgba(255, 138, 138, 0.16); --green-ink: #8fd3a4; --green-tint: rgba(95, 191, 128, 0.18);
    --amber-ink: #f2c26b; --amber-tint: rgba(242, 184, 75, 0.16); --teal-ink: #72d4cf; --teal-tint: rgba(63, 186, 181, 0.18);
    --navy-tint: rgba(169, 156, 240, 0.18); --dusk-ink: #c6bcf5;
    position: relative; z-index: 2; color: var(--ink); }
  /* Paper: what opens from the band (the clinic menu, the ⓘ, Snooze) is in the page's colors again. */
  body.portal .dusk :is([popover], .snooze-pop, dialog) {
    color-scheme: var(--paper-scheme);
    --ink: var(--paper-ink); --ink-2: var(--paper-ink-2); --muted: var(--paper-muted); --surface: var(--paper-surface);
    --surface-2: var(--paper-surface-2); --line: var(--paper-line); --line-2: var(--paper-line-2); --field: var(--paper-field);
    --accent: var(--paper-accent); --accent-hover: var(--paper-accent-hover); --on-accent: var(--paper-on-accent);
    --accent-ink: var(--paper-accent-ink); --accent-tint: var(--paper-accent-tint); --focus: var(--paper-focus);
    --red: var(--paper-red); --red-tint: var(--paper-red-tint); --green-ink: var(--paper-green-ink);
    --green-tint: var(--paper-green-tint); --amber-ink: var(--paper-amber-ink); --amber-tint: var(--paper-amber-tint);
    --navy-tint: var(--paper-navy-tint); --dusk-ink: var(--paper-dusk-ink); color: var(--ink); }

  /* The artwork: stars high on the right, the horizon along the bottom, the dune in the page's color over its edge. */
  body.portal .dusk-art { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
    background: url("art/band.1959d9888111.svg") 50% 100% / 100% var(--art-h) no-repeat; filter: var(--art-filter); }
  body.portal .dusk-art::before { content: ""; position: absolute; top: 0; right: 0; width: 58%;
    bottom: calc(var(--art-h) * 0.55); background: url("art/stars.8cebdd25e3cd.svg") 50% 0 / cover no-repeat; opacity: 0.75;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 45%); mask-image: linear-gradient(90deg, transparent, #000 45%); }
  body.portal .dusk::after { content: ""; position: absolute; z-index: 1; left: 0; right: 0; bottom: -1px; height: 10px;
    pointer-events: none; background: var(--page);
    -webkit-mask: url("art/dune.ab542ac4e9ce.svg") 0 100% / 100% 100% no-repeat; mask: url("art/dune.ab542ac4e9ce.svg") 0 100% / 100% 100% no-repeat; }
  /* A page with no header: just the top row and a slim horizon. */
  body.portal .dusk:not(:has(> .hero, .pagehead-main > *, .pagehead-actions > *)) { padding-bottom: 34px; }

  /* --- Top row: the mark, the main menu, the clinic menu ----------------------------------------------------------- */
  body.portal .topbar { height: var(--bar-h); padding: 0 2rem; gap: 0.5rem; justify-content: flex-start;
    background: none; border: 0; }
  body.portal .brand { flex: none; gap: 0.6rem; min-height: 44px; color: var(--on-sky); }
  body.portal .brand-mark { width: 32px; height: 32px; border-radius: 9px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 0 20px rgba(240, 136, 63, 0.3); }
  body.portal .brand-name { color: var(--on-sky); font: 700 1.2rem/1 var(--font-display); letter-spacing: 0.005em; }
  body.portal .mainnav { gap: 0.15rem; margin-left: 1.1rem; }
  body.portal .topbar .mainnav a { min-height: 40px; padding: 0 0.95rem; border-radius: 999px; color: var(--on-sky-2);
    font-weight: 500; font-size: 0.95rem; }
  body.portal .topbar .mainnav a:hover { background: rgba(255, 255, 255, 0.09); color: var(--on-sky); }
  body.portal .topbar .mainnav a[aria-current="page"] { color: var(--gold-soft); font-weight: 600;
    background: rgba(255, 217, 143, 0.12); box-shadow: inset 0 0 0 1px rgba(255, 217, 143, 0.4); }
  body.portal .topbar .topnav:not(.mainnav) { margin-left: auto; } /* signed out: "Sign in" on the right */

  /* --- The page's header: title on the sky, its buttons on the right --------------------------------------------- */
  body.portal .pagehead, body.portal .dusk > .hero { width: min(var(--col), 100% - 4rem); margin: 0 auto;
    padding: 0.2rem 0 var(--art-pad); }
  body.portal .pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 0.75rem 1.5rem; }
  body.portal .pagehead:not(:has(.pagehead-main > *, .pagehead-actions > *)) { display: none; }
  body.portal .pagehead-main { flex: 1 1 22rem; min-width: 0; }
  body.portal .pagehead-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
  body.portal .pagehead-actions:not(:has(*)) { display: none; }
  /* Pages that still bring a .hero: the same header, in the band. */
  body.portal .dusk > .hero { background: none; overflow: visible; }
  body.portal .dusk > .hero .hero-inner { max-width: none; gap: 0.75rem 1.5rem; }
  body.portal .dusk > .hero .back { margin-bottom: 0.35rem; }

  body.portal .dusk :is(.pagehead, .hero) h1 { margin: 0; color: #ffffff; font: 750 2rem/1.04 var(--font-display);
    letter-spacing: -0.038em; text-wrap: balance; }
  @supports ((-webkit-background-clip: text) or (background-clip: text)) {
    body.portal .dusk :is(.pagehead, .hero) h1 { /* the business page's title light: white warming to apricot */
      background: linear-gradient(180deg, #ffffff 35%, #ffeccc 68%, #ffc98c 100%); -webkit-background-clip: text;
      background-clip: text; color: transparent; padding-bottom: 0.05em; }
  }
  body.portal .dusk :is(.page-eyebrow, .hero .eyebrow) { display: flex; align-items: center; gap: 0.5rem;
    margin: 0 0 0.3rem; color: var(--sun-ink); font: 600 0.72rem/1.2 var(--font-ui); letter-spacing: 0.14em;
    text-transform: uppercase; }
  body.portal .dusk :is(.page-eyebrow, .hero .eyebrow)::before { /* a tiny banded sun, as in the mark */
    content: ""; display: block; width: 16px; height: 9px; border-radius: 16px 16px 0 0; flex: none;
    background: linear-gradient(180deg, #ffd98f 0 56%, transparent 56% 70%, #f4a254 70%); }
  body.portal .dusk :is(.page-sub, .hero .sub, .hero .lead) { margin: 0.3rem 0 0; color: var(--on-sky-2);
    font-size: 0.95rem; line-height: 1.45; }
  body.portal .dusk .hero-stats { margin-top: 0.7rem; }

  /* Buttons on the sky: the sun's gold for the main action, a quiet outline for the rest (as on the business page). */
  body.portal .dusk :is(.pagehead, .hero) .btn.primary:not(:is([popover], .snooze-pop) *) { border-color: transparent;
    color: #1d1838; background: linear-gradient(180deg, #ffe4ab, #ffd98f 45%, #f5ae63);
    box-shadow: 0 10px 26px -12px rgba(240, 136, 63, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
  body.portal .dusk :is(.pagehead, .hero) .btn.primary:not(:is([popover], .snooze-pop) *):hover {
    background: linear-gradient(180deg, #ffecc2, #ffe1a6 45%, #f7bb78); }
  body.portal .dusk :is(.pagehead, .hero) .btn:not(.primary):not(:is([popover], .snooze-pop) *) { color: var(--on-sky);
    background: #241c44; border-color: rgba(255, 255, 255, 0.5); box-shadow: none; }
  body.portal .dusk :is(.pagehead, .hero) .btn:not(.primary):not(:is([popover], .snooze-pop) *):hover {
    background: #342a5a; border-color: rgba(255, 255, 255, 0.72); }
  body.portal .dusk .hero .sub a { width: 28px; height: 28px; background: #241c44; color: var(--on-sky);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5); }
  body.portal .dusk .hero .sub a:hover { background: #342a5a; }

  /* --- Phones and narrow windows ---------------------------------------------------------------------------------- */
  @media (max-width: 760px) {
    body.portal .topbar { padding: 0 1rem; }
    body.portal .mainnav { margin-left: 0.5rem; }
    body.portal .topbar .mainnav a { padding: 0 0.7rem; font-size: 0.92rem; }
  }
  @media (max-width: 700px) {
    body.portal { --bar-h: 52px; --art-h: 58px; --art-pad: 24px; }
    body.portal .pagehead, body.portal .dusk > .hero { width: calc(100% - 2rem); }
    body.portal .pagehead { flex-direction: column; align-items: stretch; }
    body.portal .pagehead-main { flex: none; }
    body.portal .pagehead-actions > .btn { flex: 1 1 auto; }
    body.portal .dusk :is(.pagehead, .hero) h1 { font-size: 1.5rem; letter-spacing: -0.03em; }
    body.portal .dusk :is(.page-sub, .hero .sub, .hero .lead) { font-size: 0.9rem; margin-top: 0.2rem; }
    body.portal .dusk :is(.page-eyebrow, .hero .eyebrow) { margin-bottom: 0.2rem; font-size: 0.66rem; }
    body.portal .dusk .hero-stats { margin-top: 0.55rem; }
  }
  @media (max-width: 560px) {
    body.portal .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
      white-space: nowrap; }
    body.portal .topbar { padding: 0 0.75rem; gap: 0.25rem; }
    body.portal .mainnav { margin-left: 0.2rem; gap: 0; }
    body.portal .topbar .mainnav a { padding: 0 0.6rem; font-size: 0.9rem; }
  }
}

/* --- The clinic menu: everything that isn't Check-ins, Patients or Devices, under the clinic's name ----------------
   A popover (no script): Escape, a tap outside or the button again closes it. Placed under its button. */
.clinic-menu { margin-left: auto; flex: none; min-width: 0; }
.menu-btn { anchor-name: --clinic-menu; display: inline-flex; align-items: center; gap: 0.4rem; max-width: 19rem;
  min-height: 40px; padding: 0 0.7rem 0 1rem; border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 999px;
  background: rgba(255, 255, 255, 0.05); color: #ffffff; font: 600 0.9rem/1.2 var(--font-ui); cursor: pointer; }
.menu-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.7); }
.menu-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.menu-btn.is-here { color: var(--gold-soft); border-color: rgba(255, 217, 143, 0.55); background: rgba(255, 217, 143, 0.12); }
.menu-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-chevron { flex: none; transition: rotate 0.15s; }
.clinic-menu:has(.menu-panel:popover-open) .menu-chevron { rotate: 180deg; }
.menu-lines { display: none; flex: none; }
@media (max-width: 760px) {
  .menu-btn { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 50%; }
  .menu-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .menu-chevron { display: none; }
  .menu-lines { display: block; }
}

.menu-panel { position: absolute; inset: auto; top: calc(var(--bar-h, 60px) - 4px); right: 1.25rem; margin: 0;
  width: min(18.5rem, 100vw - 1.5rem); max-height: calc(100vh - var(--bar-h, 60px)); overflow: auto; padding: 0.4rem;
  border: 1px solid var(--line-2); border-radius: 16px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg), 0 18px 40px -18px rgba(29, 24, 56, 0.45); font-size: 0.92rem; line-height: 1.35; }
@supports (position-anchor: --a) {
  .menu-panel { position-anchor: --clinic-menu; top: calc(anchor(bottom) + 8px); right: anchor(right); }
}
@media (max-width: 760px) { .menu-panel { right: 0.75rem; } }
.menu-who { display: grid; gap: 0.1rem; margin: 0; padding: 0.55rem 0.7rem 0.65rem; }
.menu-who strong { color: var(--ink); font: 700 0.98rem/1.25 var(--font-display); letter-spacing: -0.01em; }
.menu-who span { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.menu-list { list-style: none; display: grid; gap: 1px; margin: 0; padding: 0.3rem 0; border-top: 1px solid var(--line); }
.menu-list a, .menu-list button, .menu-signout button { display: flex; align-items: center; gap: 0.7rem; width: 100%;
  min-height: 40px; padding: 0.4rem 0.7rem; border: 0; border-radius: 10px; background: none; color: var(--ink);
  font: 500 0.92rem/1.3 var(--font-ui); text-align: left; text-decoration: none; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover, .menu-signout button:hover { background: var(--surface-2); }
.menu-list a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-ink); font-weight: 600; }
.menu-list .icon { width: 18px; height: 18px; color: var(--muted); }
.menu-list a[aria-current="page"] .icon { color: inherit; }
.menu-list kbd { margin-left: auto; }
.menu-install [data-install]:not([hidden]) + a { display: none; } /* "Install" when the browser offers it */
.menu-legal a { min-height: 32px; padding-block: 0.3rem; color: var(--ink-2); font-size: 0.84rem; }
.menu-signout { margin: 0; padding: 0.3rem 0 0; border-top: 1px solid var(--line); }
.menu-signout .icon { width: 18px; height: 18px; color: var(--muted); }
:is(.menu-list, .menu-signout) :focus-visible { outline-offset: -2px; }
@media (prefers-reduced-motion: no-preference) {
  .menu-panel:popover-open { transition: opacity 0.14s ease-out, translate 0.14s ease-out; }
  @starting-style { .menu-panel:popover-open { opacity: 0; translate: 0 -4px; } }
}

/* --- Below the band: the view-only note, messages, the slim footer ------------------------------------------------- */
body.portal .viewonly-bar { width: fit-content; max-width: calc(100% - 2rem); margin: 1rem auto 0; padding: 0.4rem 1rem;
  border-radius: 999px; background: var(--amber-tint); color: var(--ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber) 40%, transparent); font-size: 0.84rem; }
body.portal .viewonly-bar .icon { width: 17px; height: 17px; color: var(--amber-ink); }
body.portal .toast { border-radius: 14px; border-left-width: 4px; font-weight: 500; }

.stafffoot { width: min(calc(1320px - 4rem), 100% - 4rem); margin: 0 auto; padding: 1.1rem 0 1.75rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 1.5rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }
body.portal:has(main.wide) .stafffoot { width: min(calc(1480px - 4rem), 100% - 4rem); }
.stafffoot > span { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--ink-2);
  font: 700 0.85rem/1 var(--font-display); }
.stafffoot > span::before { content: ""; width: 18px; height: 18px; border-radius: 5px;
  background: url("icons/interlude-mark.b9ad636e27d3.svg") center / contain no-repeat; }
.stafffoot nav { display: flex; flex-wrap: wrap; gap: 0 1.1rem; }
.stafffoot a { display: inline-flex; align-items: center; min-height: 28px; color: var(--muted); text-decoration: none; }
.stafffoot a:hover { color: var(--accent-ink); text-decoration: underline; }
@media (max-width: 700px) { .stafffoot { width: calc(100% - 2rem); } }

/* --- The working pages: sand page, white cards, the site's display type ------------------------------------------- */
body.portal main :is(h1, h2) { font-weight: 700; letter-spacing: -0.022em; }
body.portal main h1 { letter-spacing: -0.036em; }

@media print {
  body.portal .dusk { background: none; color: inherit; }
  body.portal .dusk-art, body.portal .dusk::after, .stafffoot, .skip-link, .clinic-menu { display: none !important; }
}
@media (forced-colors: active) {
  body.portal .dusk-art, body.portal .dusk::after { display: none; }
  body.portal .dusk :is(.pagehead, .hero) h1 { background: none; color: CanvasText; }
  .menu-btn, .menu-panel { border: 1px solid CanvasText; }
}
/* ===== end 1 ===== */




/* ===== 2. "ⓘ" help popovers (_help.html) ===== */
.help-btn {
  display: inline-grid; place-items: center;
  inline-size: 28px; block-size: 28px; padding: 0; margin-inline-start: 4px;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  cursor: pointer; vertical-align: middle; line-height: 1;
}
.help-btn:hover { color: var(--ink); background: var(--surface-2); }
.help-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.help-icon { display: block; }
.help-pop {
  inset: 0; margin: auto; inline-size: min(30rem, calc(100vw - 32px)); max-block-size: min(70vh, 36rem);
  overflow: auto; padding: 18px 20px 20px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  font: inherit; font-size: 0.95rem; line-height: 1.5; text-align: start;
}
.help-pop::backdrop { background: rgba(29, 24, 56, 0.35); }
.help-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-block-end: 6px; }
.help-title { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.help-close {
  flex: none; inline-size: 32px; block-size: 32px; margin: -4px -6px 0 0; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.help-close:hover { color: var(--ink); background: var(--surface-2); }
.help-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.help-pop p { margin: 0 0 0.6em; }
.help-pop p:last-child, .help-pop ul:last-child { margin-block-end: 0; }
.help-pop ul { margin: 0 0 0.6em; padding-inline-start: 1.2em; }
/* ===== end 2 ===== */




/* ===== 3. Patients list, patient form (new & edit), Team, Sign-in & security ===== */

/* Patient form (edit, patient_form.html): a section menu · the form in sections · a side column (connection, then
   archive or delete). One Save, in a bar that stays at the bottom of the screen while the form is in view.
   Fields come from _pf_field.html: label (+ ⓘ), input, a short hint, errors. */
.pf-layout { display: grid; grid-template-columns: 10.5rem minmax(0, 1fr) 20rem; gap: 1.25rem; align-items: start; }
.pf-nav { position: sticky; top: 1rem; }
.pf-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.pf-nav a { display: block; padding: 0.4rem 0.75rem; border-radius: 10px; color: var(--ink-2); text-decoration: none;
  font-size: 0.9rem; font-weight: 500; line-height: 1.3; }
.pf-nav a:hover { background: var(--surface-2); color: var(--ink); }
.pf-form { min-width: 0; }
.pf-side { min-width: 0; }
.pf-section { scroll-margin-top: 1rem; }
.pf-section:target { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent), var(--shadow); }
.pf-viewonly { margin: 0 0 0.9rem; color: var(--muted); font-size: 0.88rem; }

.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); gap: 0.9rem 1.1rem; }
.pf-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pf-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
/* In a grid: label / input / hint on the grid's rows (subgrid), so a wrapped label doesn't push its input down. */
.pf-grid > .pf-field { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0.3rem; align-content: start; }
.pf-grid > .pf-field > .pf-label { align-self: end; }
.pf-field.wide, .pf-check.wide { grid-column: 1 / -1; }
.pf-field.span2 { grid-column: span 2; }
.pf-label { display: block; min-height: 28px; line-height: 1.35; }
.pf-label label { font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.pf-label .help-btn { margin-block: -2px; }
/* The ⓘ hangs into room kept free at the end of the line, so it always stays with the label's last word. */
.pf-label:has(> .help-btn) { padding-inline-end: 32px; }
.pf-label > .help-btn { margin-inline-end: -32px; } /* 4px + 28px - 32px: takes no room on the line */
.pf-below:empty { display: none; }
.pf-hint { display: block; font-size: 0.8rem; line-height: 1.4; color: var(--muted); }
.pf-form textarea, .pf-form input[type=date], .pf-new textarea {
  font: 400 0.95rem var(--font-ui); padding: 0.65rem 0.85rem; border-radius: 12px; border: 1px solid var(--field);
  background: var(--surface); color: var(--ink); width: 100%; }
.pf-form textarea { resize: vertical; }
.pf-form :is(input, select, textarea):disabled { opacity: 1; color: var(--ink-2); background: var(--surface-2);
  border-color: var(--line-2); }
.pf-check { display: flex; gap: 0.6rem; align-items: flex-start; min-width: 0; }
.pf-check input[type=checkbox] { flex: none; width: 1.25rem; height: 1.25rem; margin: 0.3rem 0 0; }
.pf-check label { cursor: pointer; }
.pf-grid > .pf-check { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0.3rem;
  grid-template-columns: auto minmax(0, 1fr); column-gap: 0.6rem; align-items: center; }
.pf-grid > .pf-check > * { grid-row: 2; }
.pf-grid > .pf-check input[type=checkbox] { margin: 0; }
.pf-field .errorlist, .pf-check .errorlist { padding-left: 0; list-style: none; }
/* Nutrients: a compact table, an "at least" and a "no more than" box per nutrient (_pf_nutrients.html). */
.pf-nut-hint { display: block; margin: 0 0 0.55rem; }
.pf-nut-wrap { overflow-x: auto; }
table.pf-nutrients { width: auto; min-width: min(100%, 32rem); border-collapse: collapse; }
table.pf-nutrients :is(th, td) { padding: 0.4rem 1rem 0.4rem 0; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--line); background: none; }
table.pf-nutrients thead th { padding-block: 0.2rem 0.45rem; font: 600 0.72rem var(--font-ui); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap; }
table.pf-nutrients tbody th { min-width: 10rem; font: 500 0.92rem/1.35 var(--font-ui); letter-spacing: 0;
  text-transform: none; color: var(--ink); white-space: normal; }
table.pf-nutrients tbody tr:last-child > * { border-bottom: 0; }
.pf-nut-unit { color: var(--muted); font-size: 0.8rem; font-weight: 400; white-space: nowrap; }
.pf-nut-ref { display: block; margin-top: 0.05rem; font-size: 0.75rem; font-weight: 400; color: var(--muted); }
table.pf-nutrients input { width: 7.5rem; }
table.pf-nutrients .errorlist { margin: 0.25rem 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--red); }
.pf-more-nutrients { margin-top: 0.8rem; }
.pf-more-nutrients > summary { cursor: pointer; font-weight: 600; min-block-size: 24px; }
.pf-more-nutrients[open] > summary { margin-bottom: 0.4rem; }

/* Program & targets: the program row on a sand tile, then the targets by kind; Athlete and Event fold. */
.pf-program { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; padding: 0.9rem 1rem 1rem;
  border-radius: 14px; background: var(--surface-2); }
.pf-program > .pf-field { flex: 1 1 14rem; }
.pf-apply { flex: 1 1 15rem; display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; }
.pf-group { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0 0; padding: 1rem 0 0; min-width: 0; }
.pf-group > legend { float: left; width: 100%; padding: 0; margin: 0 0 0.55rem; display: flex; align-items: center;
  font: 650 0.98rem var(--font-display); color: var(--ink); }
.pf-group > legend + * { clear: both; }
.pf-fold { border-top: 1px solid var(--line); margin-top: 1.2rem; padding-top: 0.75rem; }
.pf-fold > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 0.15rem 0.6rem; min-height: 32px; padding: 0.2rem 0; border-radius: 8px; }
.pf-fold > summary::-webkit-details-marker { display: none; }
.pf-fold > summary::before { content: ""; flex: none; align-self: center; width: 7px; height: 7px; margin: 0 0.25rem 0.2rem 0.1rem;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(-45deg); }
.pf-fold[open] > summary::before { transform: rotate(45deg); margin-bottom: 0.35rem; }
.pf-fold > summary:hover .pf-fold-title { color: var(--accent-ink); }
.pf-fold-title { font: 650 0.98rem var(--font-display); color: var(--ink); }
.pf-fold-tag { font-size: 0.82rem; color: var(--muted); }
.pf-fold > .pf-group { border-top: 0; margin-top: 0.35rem; padding-top: 0; }
.pf-about { margin: 0 0 0.75rem; font-size: 0.85rem; color: var(--ink-2); }

/* What they see: two small groups of switches. */
.pf-title { display: flex; align-items: center; gap: 0.15rem; margin-bottom: 0.8rem; }
.pf-title h2 { margin: 0; }
.pf-switches { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 0.75rem; }
.pf-switches + .pf-switches { margin-top: 1.2rem; }
.pf-switches > legend { padding: 0; margin-bottom: 0.6rem; font: 600 0.76rem var(--font-ui); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); }
.pf-switches .pf-label { min-height: 0; }
.pf-switches .pf-check input[type=checkbox] { margin-top: 0.15rem; }

/* The one Save. Scrolling to a field (Tab, an error link) keeps it clear of the bar (WCAG 2.4.11). */
html:has(.pf-savebar) { scroll-padding-bottom: 5.5rem; }
.pf-savebar { position: sticky; bottom: 0.75rem; z-index: 3; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.9rem; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface);
  box-shadow: var(--shadow-lg); }
.pf-errors { margin: 0 0 1.1rem; padding: 0.9rem 1.1rem; border-radius: 14px; background: var(--red-tint);
  border: 1px solid color-mix(in srgb, var(--red) 45%, transparent); }
.pf-errors h2 { margin: 0 0 0.3rem; font-size: 1rem; }
.pf-errors ul { margin: 0; padding-left: 1.1rem; }

/* Side column: connection (consent, app, link) and, apart and folded, archive or delete. */
.pf-part + .pf-part { border-top: 1px solid var(--line); margin-top: 0.9rem; padding-top: 0.9rem; }
.pf-part h3 { margin: 0 0 0.3rem; font-size: 0.92rem; display: flex; align-items: center; gap: 0.4rem; }
.pf-part h3 .icon { width: 17px; height: 17px; color: var(--ink-2); }
.pf-part p { margin: 0.15rem 0; }
.pf-part .manual { margin-top: 0.7rem; }
.pf-part .manual > summary { padding-block: 0.15rem; }
.pf-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; margin-top: 0.55rem; }
.pf-danger { margin-top: 1.75rem; border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.pf-danger > summary h2 { font-size: 1rem; }
.pf-delete { display: grid; gap: 0.4rem; margin-top: 0.6rem; }
.pf-delete label { font-size: 0.88rem; font-weight: 600; }
.pf-delete .btn { justify-self: start; margin-top: 0.2rem; }

/* The ⓘ lists: programs and their starting targets, what each switch shows. */
.help-pop .pf-programs { margin: 0.5rem 0 0; display: grid; gap: 0.6rem; }
.pf-programs dt { font-weight: 600; }
.pf-programs dd { margin: 0.1rem 0 0; color: var(--ink-2); }

/* Invite a patient (patient_new.html): one card, one screen. */
.pf-new .pf-grid { margin-bottom: 1rem; }
.pf-note { display: flex; align-items: flex-start; gap: 0.45rem; margin: 0 0 1rem; color: var(--ink-2); font-size: 0.9rem; }
.pf-note .icon { width: 17px; height: 17px; margin-top: 0.15rem; color: var(--accent-ink); }

@media (max-width: 1180px) {
  .pf-layout { grid-template-columns: minmax(0, 1fr) 19rem; }
  .pf-nav { grid-column: 1 / -1; position: static; }
  .pf-nav ul { display: flex; flex-wrap: wrap; gap: 0.4rem; }
  .pf-nav a { padding: 0.35rem 0.85rem; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface);
    font-size: 0.85rem; }
}
@media (max-width: 900px) {
  .pf-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .pf-danger { margin-top: 0.5rem; }
}
@media (max-width: 700px) {
  .pf-form textarea, .pf-form input[type=date] { font-size: 16px; } /* 16px stops iPhone zooming in */
}
@media (max-width: 600px) {
  .pf-grid.two { grid-template-columns: minmax(0, 1fr); }
  .pf-group .pf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 0.75rem; }
  .pf-contact .pf-grid { grid-template-columns: minmax(0, 1fr); } /* an email address needs the whole width */
  .pf-savebar { bottom: 0.5rem; }
  .pf-savebar .btn { flex: 1; }
}

/* The small staff pages (Team, Sign-in & security, the link pages, Desktop app): a card's heading with its ⓘ. */
.card-title { display: flex; align-items: center; gap: 0.15rem; margin-bottom: 0.95rem; }
.card-title h2 { margin: 0; }
.install-head .card-title { margin: 0; }
.link-card textarea { margin-bottom: 0.75rem; }
.formcard > .team-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.team-fields > div { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
@media (max-width: 600px) { .formcard > .team-fields { grid-template-columns: minmax(0, 1fr); } }
/* Team: a person's role picker and Remove move under their name when the row is too narrow for both. */
.team-list li { flex-wrap: wrap; }
.team-list li > div:first-child { flex: 1 1 13rem; }
.team-list li > .actions { min-width: auto; justify-content: flex-end; }
.link-card .footnote { margin-bottom: 0; }
/* Invitations by email (_invite_email.html, team.html): when it went out, and Resend to the same or a new address.
   On a phone the address takes the row and the button goes under it. */
.invite-email-card h2 { display: flex; align-items: center; gap: 0.45rem; }
.invite-email-card > .muted { margin: -0.4rem 0 0.75rem; }
.invite-emailed { display: flex; align-items: center; gap: 0.45rem; margin: 0 0 0.75rem; font-weight: 600;
  color: var(--green-ink); }
.invite-emailed .icon { width: 18px; height: 18px; flex: none; }
.invite-address { margin: 0 0 0.6rem; }
.invite-email-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.invite-email-form input[type=email] { flex: 1 1 14rem; min-width: 0; width: auto; }
.pf-part .invite-email-form input[type=email] { flex-basis: 100%; }
.formcard .check-line { display: flex; align-items: center; gap: 0.6rem; font-size: 0.92rem; font-weight: 500;
  color: var(--ink); }
.formcard .check-line input[type=checkbox] { flex: none; width: 1.15rem; height: 1.15rem; margin: 0; }

/* Patients list: the "Asked for" heading's ⓘ; on phones each patient is a compact card (name and links on top). */
.th-help { display: inline-flex; align-items: center; gap: 0.1rem; }
.th-help .help-btn { inline-size: 24px; block-size: 24px; margin: -4px 0; }
table.patient-list .pstatus { white-space: normal; }
@media (max-width: 700px) {
  table.cards.patient-list tr { position: relative; gap: 0.6rem 1rem; padding: 0.9rem 1rem; }
  table.cards.patient-list td:first-child { padding-right: 7.5rem; }
  table.cards.patient-list td.actions-cell { position: absolute; top: 0.9rem; right: 1rem; padding: 0; }
  table.cards.patient-list td.actions-cell a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 0.2rem; }
  table.cards.patient-list td:has(> .nil:only-child) { display: none; }
  table.cards.patient-list td[data-label]::before { margin-bottom: 0.25rem; }
  table.cards.patient-list .small { margin-top: 0.15rem; }
}

/* ===== end 3 ===== */




/* ===== 4. Device & app guide (the staff page; the patient's copy stays in app.css) ===== */
/* device_guide.html: one card, a row per device or app grouped by kind. Each row is a <details> whose summary is the
   row, so tapping it opens the details in place. Phones and iPads: each row lists what it shares as small chips.
   1000px and wider: a grid with a column per kind of data (✓ shares it, ◐ shares part of it, a dot: doesn't). */
.dg { --dg-cols: minmax(10.5rem, 1.25fr) minmax(12rem, 3.2fr) repeat(7, minmax(3.3rem, 0.5fr)) 1.5rem; }
.dg-talk { display: flex; align-items: center; gap: 0.15rem; margin: 0 0 0.6rem; color: var(--ink-2); font-size: 0.9rem; }
.dg-talk p { margin: 0; }
.dg .help-btn { flex: none; }
.dg-talk .icon { color: var(--accent-ink); width: 18px; height: 18px; margin-inline-end: 0.35rem; }

.dg-cols { display: none; }
.dg-kind-head { display: flex; align-items: center; padding: 0.8rem 0.6rem 0.35rem; }
.dg-kind-head h2 { margin: 0; font-size: 1rem; gap: 0.55rem; }
.dg-kind-head .tile-icon { width: 30px; height: 30px; border-radius: 9px; }
.dg-kind-head .tile-icon .icon { width: 17px; height: 17px; }
.dg-items { list-style: none; margin: 0; padding: 0; }
.dg-items > li { border-top: 1px solid var(--line); }
.dg-items > li:last-child { border-bottom: 1px solid var(--line); }

.dg-item > summary { display: block; list-style: none; cursor: pointer; border-radius: 10px; }
.dg-item > summary::-webkit-details-marker { display: none; }
.dg-item > summary:hover { background: var(--surface-2); }
.dg-item > summary:hover .dg-name { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.dg-item > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.dg-item[open] { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); border-radius: 10px; }
.dg-item[open] > summary:hover { background: transparent; }

.dg-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 1.5rem; column-gap: 0.6rem;
  row-gap: 0.25rem; grid-template-areas: "name chev" "price chev" "marks chev"; align-items: center;
  padding: 0.5rem 0.6rem; font-size: 0.9rem; }
.dg-name { grid-area: name; font-weight: 600; color: var(--ink); }
.dg-price { grid-area: price; min-width: 0; color: var(--ink); }
.dg-price strong { font-weight: 600; }
.dg-plan { color: var(--muted); font-size: 0.84rem; }
.dg-marks { grid-area: marks; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.dg-chev { grid-area: chev; display: grid; place-items: center; color: var(--muted); }
.dg-chev .icon { width: 16px; height: 16px; transition: transform 0.15s; }
.dg-item[open] .dg-chev .icon { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .dg-chev .icon { transition: none; } }

/* The kinds of data it shares: chips on phones and iPads */
.dg-m { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.12rem 0.55rem; border-radius: 999px;
  font: 600 0.76rem/1.4 var(--font-ui); background: var(--green-tint); color: var(--green-ink); }
.dg-m.some { background: var(--amber-tint); color: var(--amber-ink); }
.dg-m.no { display: none; }
.dg-ic { font-weight: 700; line-height: 1; }
.dg-ic.yes { color: var(--green-ink); }
.dg-ic.some { color: var(--amber-ink); }
.dg-none { color: var(--muted); font-size: 0.8rem; }
.dg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* A row's details */
.dg-more { display: grid; gap: 0.6rem; padding: 0.1rem 0.6rem 0.95rem; }
.dg-facts { margin: 0; display: grid; gap: 0.6rem 1.75rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  font-size: 0.88rem; }
.dg-facts dt { font: 600 0.72rem var(--font-ui); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.dg-facts dd { margin: 0.1rem 0 0; color: var(--ink-2); }
.dg-offer, .dg-link { margin: 0; font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.dg-link a { font-weight: 600; display: inline-flex; align-items: center; min-height: 24px; }

.dg-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.2rem 1.5rem;
  margin-top: 0.75rem; padding: 0 0.6rem; color: var(--muted); font-size: 0.8rem; }
.dg-foot p { margin: 0; }
.dg-key .dg-ic + .dg-ic { margin-inline-start: 0.6rem; }
.dg-asof .help-btn { margin-inline-start: 0; }

/* iPads: name and price on the left, what it shares on the right */
@media (min-width: 600px) {
  .dg-row { grid-template-columns: minmax(10rem, 1fr) minmax(0, 1.3fr) 1.5rem;
    grid-template-areas: "name marks chev" "price marks chev"; }
}

/* Desktop: the grid, with its column names staying on screen while you scroll */
@media (min-width: 1000px) {
  .dg-cols, .dg-row { grid-template-columns: var(--dg-cols); grid-template-areas: none; column-gap: 0.5rem; }
  .dg-cols { display: grid; align-items: end; position: sticky; top: var(--dg-sticky-top, 0px); z-index: 2;
    padding: 0.55rem 0.6rem 0.5rem; background: var(--surface); border-bottom: 1px solid var(--line-2);
    font: 600 0.74rem/1.25 var(--font-ui); color: var(--muted); }
  /* Never let the column names cover what has keyboard focus (WCAG 2.4.11) */
  .dg :is(summary, .help-btn, a) { scroll-margin-top: calc(var(--dg-sticky-top, 0px) + 4rem); }
  .dg-col-data { text-align: center; }
  .dg-row { min-height: 2.4rem; padding-block: 0.3rem; row-gap: 0; }
  .dg-name, .dg-price, .dg-chev { grid-area: auto; }
  .dg-marks { display: contents; }
  .dg-m, .dg-m.some, .dg-m.no { display: flex; justify-content: center; padding: 0; background: none; font-size: 1rem; }
  .dg-m.no::before { content: ""; inline-size: 4px; block-size: 4px; border-radius: 50%; background: var(--line-2); }
  .dg-lb, .dg-none { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ===== end 4 ===== */




/* ===== 5. Owner page ===== */
/* Owner page (owner.html, monitoring/owner.py): tabs, each its own address (/owner/?tab=…). The map, its dialog and
   the data-flow table are in system-map.css. */
.owner-tabs { display: flex; flex-wrap: wrap; gap: 4px; inline-size: fit-content; max-inline-size: 100%;
  margin: 0 0 1.25rem; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); }
.owner-tabs a { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; min-block-size: 40px;
  padding: 0.4rem 0.95rem; border-radius: 10px; color: var(--ink-2); font: 600 0.92rem var(--font-ui);
  text-decoration: none; white-space: nowrap; }
.owner-tabs a:hover { background: var(--surface-2); color: var(--ink); }
.owner-tabs a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.owner-tabs .icon { inline-size: 17px; block-size: 17px; flex: none; }
.owner-count { display: inline-grid; place-items: center; min-inline-size: 1.45rem; block-size: 1.35rem;
  padding: 0 0.4rem; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 0.74rem; font-weight: 700; line-height: 1; }
@media (max-width: 640px) {
  .owner-tabs { inline-size: auto; }
  .owner-tabs a { flex: 1 1 auto; padding-inline: 0.75rem; }
  .owner-tabs .icon { display: none; }
}

/* A section's heading row: the heading, its ⓘ, and sometimes a link at the end */
.owner-head { display: flex; align-items: center; gap: 0.25rem 0.5rem; margin-block-end: 0.95rem; }
.owner-head h2 { flex-wrap: nowrap; margin: 0; min-inline-size: 0; }
.owner-head .help-btn { flex: none; }
.owner-more { display: inline-flex; align-items: center; min-block-size: 24px; margin-inline-start: auto;
  font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.owner-page details.handled-requests > summary { display: list-item; min-block-size: 24px; padding-block: 2px; }
.owner-section { margin-block-end: 1.1rem; }
.owner-pair, .owner-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.1rem;
  align-items: start; }
.owner-top { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
@media (max-width: 900px) {
  .owner-pair, .owner-top { grid-template-columns: minmax(0, 1fr); }
}

/* Clinics: the counts and times stay on one line beside the clinic's name (on a phone each row is a card) */
@media (min-width: 1100px) {
  .owner-clinics td:is([data-label="People"], [data-label="Last staff sign-in"]) { white-space: nowrap; }
}
/* Keeps the table's screen-reader-only header text inside the scrolling card (it's absolutely positioned). */
.owner-section .tablewrap { position: relative; }

/* Overview: what needs you now, and the system's live status */
.now-list li { flex-wrap: wrap; }
.now-list li > div:first-child { flex: 1 1 16rem; }
.now-list .t-warn { margin-inline: -0.75rem; padding-inline: 0.75rem; border-radius: 12px; border-top-color: transparent;
  background: var(--amber-tint); }
.now-list .t-warn + li { border-top-color: transparent; }
.now-clear { display: flex; align-items: center; gap: 0.5rem; margin: 0; color: var(--green-ink); font-weight: 600; }
.now-clear .icon { inline-size: 18px; block-size: 18px; }
.sys-list { list-style: none; margin: 0; padding: 0; }
.sys-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.2rem 1rem;
  padding: 0.6rem 0; border-top: 1px solid var(--line); }
.sys-list li:first-child { border-top: 0; padding-top: 0; }
.sys-name { font-weight: 600; }
.sys-list .mstatus { font-size: 0.85rem; font-weight: 500; color: var(--ink-2); overflow-wrap: anywhere; }
.help-pop .flow-key { flex-direction: column; flex-wrap: nowrap; gap: 0.45rem; margin: 0 0 0.8em; padding: 0;
  font-size: 0.92rem; color: var(--ink); }
.help-pop .flow-key li { align-items: flex-start; }
.help-pop .flow-key .fsw { flex: none; margin-block-start: 0.3em; }

/* Requests: one row each, the actions at the end */
.owner-page .requests { gap: 0; margin: 0; }
.owner-page .request { grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 0.5rem 1.25rem;
  padding: 0.85rem 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.owner-page .request:first-child { border-top: 0; padding-top: 0; }
.request-main { display: grid; gap: 0.3rem; min-inline-size: 0; }
.request-from { margin: 0; font-size: 0.9rem; color: var(--ink-2); overflow-wrap: anywhere; }
.owner-page .request-note { max-inline-size: 75ch; }
.request-actions { justify-content: flex-end; }
@media (max-width: 760px) {
  .owner-page .request { grid-template-columns: minmax(0, 1fr); }
  .request-actions { justify-content: flex-start; }
}

/* Stories */
.story-rule { margin: -0.4rem 0 0.8rem; color: var(--ink-2); }
/* ===== end 5 ===== */




/* ===== 6. Check-ins and the patient page ===== */

/* --- 6a. Check-ins (dashboard.html) ------------------------------------------------------------------------------ */

/* The week in the page header, with the previous / next week arrows. */
.week-nav { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.week-nav a { display: inline-grid; place-items: center; inline-size: 32px; block-size: 32px; border-radius: 50%;
  color: inherit; text-decoration: none; box-shadow: inset 0 0 0 1px currentColor; }
.week-nav a .icon { width: 16px; height: 16px; }
.next-up { display: contents; }

/* One quiet line: how many are high, medium, everyone else and snoozed (each a link to its section), the samples
   note, the ⓘ. */
.cx-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1.25rem; margin: 0 0 0.9rem;
  font-size: 0.9rem; color: var(--ink-2); }
.cx-counts { margin: 0; color: var(--muted); }
.cx-counts a, .cx-counts > span:not([aria-hidden]) { display: inline-block; padding-block: 0.3rem; color: var(--ink-2);
  text-decoration: none; white-space: nowrap; }
.cx-counts a:hover { color: var(--ink); text-decoration: underline; }
.cx-counts strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.cx-samples { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; font-size: 0.82rem; color: var(--muted); }
.cx-samples .icon { width: 14px; height: 14px; }
.cx-summary > .help-btn { margin-inline-start: auto; }
.help-pop .table-legend { color: var(--ink-2); font-size: 0.88rem; }
.help-pop .table-legend .dot { width: 15px; height: 15px; font-size: 0.55rem; vertical-align: -2px; margin: 0 0.1rem; }
.help-pop kbd { font: 600 0.8rem var(--font-ui); padding: 0.05rem 0.4rem; border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--line-2); background: var(--surface-2); }

/* The list: a card per patient under High, Medium or Everyone else (priority.py; there's no schedule). The whole card
   is one link to the patient's page: the name's link stretches over it (::after), and only the approve controls sit
   above it. A card is who, their key fields against their targets (section 8 outlines one off target) and, on the
   right, the days since the last check-in. The week's flags are on the patient's page. */
.pc-group { margin: 0 0 1.6rem; scroll-margin-top: 0.75rem; }
.pc-group > .group-head, .snoozed-group .group-head { display: flex; align-items: center; gap: 0.6rem;
  margin: 0 0 0.7rem; color: var(--ink); font: 650 1.05rem/1.3 var(--font-display); letter-spacing: -0.012em; }
.pc-group .group-head .muted { font: 400 0.85rem var(--font-ui); letter-spacing: 0; }
.pc-group .group-head .tile-icon { width: 28px; height: 28px; border-radius: 9px; }
.pc-group .group-head .tile-icon .icon { width: 15px; height: 15px; }
.pc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.pc { position: relative; display: grid;
  grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr) minmax(11rem, 13.5rem);
  grid-template-areas: "who week check"; align-items: center; gap: 0.65rem 1.25rem; margin: 0; padding: 0.75rem 1rem;
  border-radius: 14px; background: var(--surface); scroll-margin-top: 0.75rem;
  box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 3px rgba(25, 20, 48, 0.07); transition: box-shadow 0.12s ease-out; }
.pc:has(.who-name:hover) { box-shadow: inset 0 0 0 1.5px var(--accent), 0 2px 8px rgba(25, 20, 48, 0.1); }
.pc-who { grid-area: who; display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.pc-who .avatar { width: 34px; height: 34px; font-size: 0.78rem; }
.pc-id { min-width: 0; }
.pc-name { margin: 0; font: 650 1rem/1.3 var(--font-ui); letter-spacing: 0; }
.pc-name .who-name { display: inline; color: var(--ink); text-decoration: none; white-space: normal; }
.pc-name .who-name::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: 14px; }
.pc:has(.who-name:hover) .who-name { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.pc-name .who-name:focus-visible { outline: none; }
.pc-name .who-name:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 2px; }
.pc-name .pin .icon { width: 14px; height: 14px; margin-inline-end: 0.25rem; vertical-align: -1px;
  color: var(--muted); }
.pc-meta { display: block; margin-top: 0.05rem; font-size: 0.8rem; color: var(--muted); }
.pc-meta .sample-tag { margin: 0 0 0 0.15rem; font-size: 0.68rem; padding: 0.05rem 0.45rem; vertical-align: 1px; }
/* "Priority: High · Off target: protein and sleep": plain words; the word High is only a little heavier, never a
   colour. Only a patient with a key field off target has the line (priority.py). */
.pc-priority { margin: 0.2rem 0 0; font-size: 0.8rem; line-height: 1.3; color: var(--ink-2); text-wrap: pretty; }
.pc-keep { white-space: nowrap; } /* a long reason wraps after the dot, never inside "Priority: High" */
.pc-priority.is-high .pc-level { font-weight: 650; color: var(--ink); }
.pc-week { grid-area: week; min-width: 0; }
/* Four columns on every card, so the tiles line up down the list. */
.pc-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; margin: 0; }
.pc-tile { min-width: 0; padding: 0.45rem 0.65rem 0.5rem; border-radius: 10px; background: var(--wash);
  box-shadow: inset 0 0 0 1px var(--line); }
.pc-tile dt { font-size: 0.74rem; font-weight: 600; line-height: 1.25; color: var(--ink-2); }
.pc-tile dd { margin: 0; font-variant-numeric: tabular-nums; }
.pc-val { margin-block: 0.1rem 0.05rem !important; font: 650 0.9rem/1.25 var(--font-ui); color: var(--ink); }
.pc-sub { font-size: 0.72rem; line-height: 1.3; color: var(--muted); text-wrap: pretty; }
.pc-check { grid-area: check; min-width: 0; text-align: right; }
.pc-since { margin: 0; font: 650 0.95rem/1.3 var(--font-ui); color: var(--ink); }
.pc-due { margin: 0.1rem 0 0; font-size: 0.82rem; color: var(--ink-2); }
/* Approve, Preview and Snooze sit above the card's link, so they never open the patient's page. */
.pc-actions { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: flex-end;
  gap: 0.2rem; margin-top: 0.45rem; }
.pc-actions .approve-btn { max-width: none; padding: 0.3rem 0.8rem; border-radius: 14px; line-height: 1.2;
  white-space: nowrap; }
.pc-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 1rem; }
.pc-actions .peek-btn { min-block-size: 24px; margin: 0; }
.pc-check .cell-note { justify-content: flex-end; text-align: left; }
.pc-check .peek { text-align: left; }
.snooze-peek { width: min(25rem, calc(100% - 2rem)); }
.snooze-note { margin: 0 0 0.9rem; font-size: 0.9rem; color: var(--ink-2); }
.snooze-choices { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.9rem; }
.pc-empty { text-align: center; }
@media (prefers-reduced-motion: reduce) { .pc { transition: none; } }

/* iPad and small laptops: the check-in moves up beside the name, the tiles take the card's whole width. */
@media (max-width: 1200px) {
  .pc { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who check" "week week"; align-items: start; }
}
/* Phones: one column (who, the check-in, the tiles 2 by 2). */
@media (max-width: 700px) {
  .cx-summary { gap: 0.3rem 0.75rem; }
  .cx-summary > .help-btn { margin-inline-start: 0; }
  .pc { grid-template-columns: minmax(0, 1fr); grid-template-areas: "who" "check" "week"; gap: 0.55rem;
    padding: 0.75rem 0.8rem 0.8rem; }
  .pc-check { text-align: left; }
  .pc-check [data-checkin] { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.75rem; }
  .pc-check .cell-note { flex-basis: 100%; justify-content: flex-start; }
  .pc-actions { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.3rem 1rem; margin-top: 0.4rem; }
  .pc-due { margin: 0; }
  .pc-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- 6b. The patient page (patient_detail.html, _patient_main.html) --------------------------------------------- */

/* Header: back to Check-ins and the program above the name; one status line under it. */
.pt-eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.75rem; }
.pt-back { display: inline-flex; align-items: center; gap: 0.3rem; min-block-size: 24px; color: inherit;
  text-decoration: none; font-weight: 600; }
.pt-back:hover { text-decoration: underline; }
.pt-back .icon { width: 15px; height: 15px; }
.pt-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; }
.pt-status > span { display: inline-flex; align-items: center; gap: 0.35rem; }
.pt-status .icon { width: 15px; height: 15px; flex: none; }
.pt-state { font-weight: 600; }
/* "Needs attention · 3 flags" is a button: the check-in period's flags and the tiles they're about
   (_flag_pop.html). */
.pt-status > .pt-flags { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 28px;
  margin: -0.15rem -0.45rem; padding: 0.15rem 0.45rem; border: 0; border-radius: 8px; background: none;
  color: inherit; font: inherit;
  font-weight: 600; text-decoration: underline dotted; text-decoration-thickness: 1px; text-underline-offset: 3px;
  cursor: pointer; }
.pt-flags:hover { background: rgba(255, 255, 255, 0.1); text-decoration-style: solid; }
.pt-flags:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.pt-flags-chev { width: 7px; height: 7px; margin: -3px 0 0 0.15rem; border: solid currentColor;
  border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }
.pt-flags[aria-expanded="true"] .pt-flags-chev { margin-top: 3px; transform: rotate(-135deg); }
.pagehead .prevnext .prevnext-pos { color: inherit; }
/* How to reach them: their email and phone number in full, each with an icon-only copy button that shows "Copied"
   for a moment (app.js). Nothing saved: a quiet "Add contact info". */
.pt-contact { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 1.1rem; }
.pt-reach { display: inline-flex; align-items: center; gap: 0.35rem; min-width: 0; }
.pt-reach > .icon { width: 15px; height: 15px; flex: none; }
.pt-value { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; user-select: all; }
.pt-copy { position: relative; display: inline-grid; place-items: center; flex: none; inline-size: 28px;
  block-size: 28px; padding: 0; margin: -2px 0 -2px -0.1rem; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); cursor: pointer; }
.pt-copy .icon { width: 15px; height: 15px; }
.pt-copy:hover { color: var(--ink); background: var(--surface-2); }
.pt-copy:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pt-copy.is-copied { color: var(--green-ink); }
.pt-copy.is-copied::after { content: "Copied"; position: absolute; left: 50%; bottom: calc(100% + 2px);
  transform: translateX(-50%); padding: 0.1rem 0.45rem; border-radius: 6px; background: var(--surface-2);
  color: var(--ink); font: 600 0.72rem/1.4 var(--font-ui); white-space: nowrap; pointer-events: none; }
.pt-add-contact { display: inline-flex; align-items: center; gap: 0.3rem; min-block-size: 24px; color: inherit;
  text-decoration: none; }
.pt-add-contact:hover { text-decoration: underline; }
.pt-add-contact .icon { width: 14px; height: 14px; }

/* The check-in period (the side column): last focus, the 7 days, the flags and every target, a row each. */
.pb-period h2 .muted { font: 400 0.85rem var(--font-ui); letter-spacing: 0; }
.pb-period .focus-line { margin: 0 0 0.75rem; }
.pw-days { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.3rem 1rem; margin: 0 0 0.75rem; }
.pw-days .dots { margin: 0; }
.pw-days .dots-days { display: flex; gap: 3px; margin: 0.2rem 0 0; }
.pw-days .dots-days span { width: 24px; text-align: center; font: 600 0.68rem/1 var(--font-ui); color: var(--muted); }
.pw-days .dots-sub { margin: 0 0 0.15rem; white-space: normal; }
.pw-flags { margin: 0 0 0.25rem; }
.pw-flags .flaglist { margin: 0; gap: 0.35rem; }
.pw-flags .flaglist .chip { margin: 0; }
.pw-flags details.why > summary { padding: 0.15rem 0.45rem; margin-left: -0.45rem; border-radius: 8px; font-size: 0.82rem;
  min-block-size: 24px; }
.pw-flags details.why > summary:hover { background: var(--surface-2); }
.pw-whys { margin: 0.25rem 0 0; padding-inline-start: 1.1rem; font-size: 0.86rem; color: var(--ink-2); line-height: 1.45; }
/* Targets you set (the side column's check-in period): one compact row each, a mark for met / not met / not enough
   data (shape and colour), this period's result on the right, the goal and the week before under it. */
.pb-targets-title { margin: 0.95rem 0 0.35rem; font-size: 0.92rem; }
.pb-targets-title .muted { font-weight: 400; }
.pb-targets { list-style: none; margin: 0; padding: 0; }
.pb-targets li { display: grid; grid-template-columns: 1.7rem minmax(0, 1fr) auto; grid-template-areas: "mark label actual"
  ". sub sub"; align-items: baseline; gap: 0.05rem 0.5rem; padding: 0.45rem 0; border-top: 1px solid var(--line);
  font-size: 0.88rem; }
.pb-targets .pw-mark { grid-area: mark; align-self: center; }
.pb-t-label { grid-area: label; font-weight: 600; color: var(--ink); }
.pb-t-actual { grid-area: actual; text-align: right; font-variant-numeric: tabular-nums; }
.pb-t-sub { grid-area: sub; font-size: 0.78rem; color: var(--ink-2); }
.pw-mark { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; font-size: 0.72rem;
  font-weight: 700; }
.pb-targets .met .pw-mark { background: var(--green-tint); color: var(--green-ink); }
.pb-targets .missed .pw-mark { background: var(--amber-tint); color: var(--amber-ink); }
.pb-targets .nodata .pw-mark { background: var(--surface-2); color: var(--muted); }
.pw-was { font-size: 0.75rem; font-weight: 700; }
.pw-was.met { color: var(--green-ink); }
.pw-was.missed { color: var(--amber-ink); }

.sub-fold { margin-top: 1.1rem; }
.sub-fold > summary { display: flex; align-items: center; gap: 0.6rem; min-block-size: 32px; list-style: none; cursor: pointer; }
.sub-fold > summary::-webkit-details-marker { display: none; }
.sub-fold > summary h3 { margin: 0; font-size: 0.95rem; }
.sub-fold > summary h3 .muted { font-weight: 400; font-size: 0.82rem; }
.sub-fold > summary::after { content: ""; width: 7px; height: 7px; border: solid var(--ink-2); border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg) translate(-2px, -2px); }
.sub-fold[open] > summary::after { transform: rotate(-135deg); }
.sub-fold > summary:hover h3 { color: var(--accent-ink); }
.sub-fold[open] > summary { margin-bottom: 0.6rem; }
.cat-none { display: flex; align-items: center; gap: 0.45rem; margin: 0.25rem 0 1rem 0.25rem; font-size: 0.85rem;
  color: var(--muted); }
.cat-none .icon { width: 15px; height: 15px; }
/* The side column: the check-in, the check-in period, then folded Plan & notes and Devices & apps. */
.focus-pick .label-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.focus-pick .label-row .help-btn { margin: 0; }
.composer-note { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 0.25rem; }
.composer-note .help-btn { margin: 0; }
.plan-fold h3 { margin: 1rem 0 0.5rem; font-size: 0.92rem; }
.plan-fold h3:first-of-type { margin-top: 0; }
.plan-fold .checklist { margin-top: 0; }
.devices-fold > summary { flex-wrap: wrap; row-gap: 0.15rem; }
.devices-fold > summary h2 { flex: 1 1 auto; }
.devices-fold .fold-line { order: 3; flex-basis: 100%; padding-inline-start: calc(30px + 0.6rem); font-size: 0.82rem;
  color: var(--ink-2); }
.devices-fold > summary::after { order: 2; }
.devices-fold .devices { margin: 0; }
.daytable-full td, .daytable-full th { white-space: nowrap; }

/* --- 6c. The patient board (patient_detail.html, _patient_main.html, _board_*.html; monitoring/board.py) ----------
   One control row (which kinds of data, the time range), then a grid of chart tiles beside the check-in's side
   column. A tile is one number, its change, one chart and one line, the same card as Check-ins' (inset hairline,
   no colour for good or bad); its name is the button that opens it large in a dialog. The time range control is
   shared with Check-ins. */

.pb-controls { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 0.6rem 1.25rem; margin: 0 0 0.85rem; }
.pb-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; min-width: 0; }
.pb-chip { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 36px; padding: 0.3rem 0.85rem;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2);
  font: 500 0.88rem/1.2 var(--font-ui); cursor: pointer; }
.pb-chip .icon { width: 15px; height: 15px; color: var(--muted); }
.pb-chip:hover { background: var(--surface-2); color: var(--ink); }
.pb-chip[aria-pressed="true"] { border-color: transparent; background: var(--accent-tint); color: var(--accent-ink);
  font-weight: 600; }
.pb-chip[aria-pressed="true"] .icon { color: inherit; }
.pb-chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* The time range: the dropdown (Custom… opens two dates), the clinician's default and the links back to it. */
.rangebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.35rem 0.9rem;
  min-width: 0; }
.range-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin: 0; }
.range-form select { width: auto; min-height: 38px; padding: 0.4rem 2rem 0.4rem 0.85rem; font-weight: 600;
  font-size: 0.9rem; }
.range-custom { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; }
.range-custom label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.84rem; color: var(--ink-2); }
.range-custom input[type=date] { min-height: 38px; padding: 0.35rem 0.6rem; border: 1px solid var(--field);
  border-radius: 12px; background: var(--surface); color: var(--ink); font: 400 0.9rem var(--font-ui); }
.range-custom input[type=date]:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.range-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.8rem; font-size: 0.82rem;
  color: var(--muted); }
.range-save { display: inline; margin: 0; }
.range-link { display: inline-flex; align-items: center; min-height: 24px; padding: 0; color: var(--accent-ink);
  font: 600 0.82rem var(--font-ui); text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 2px; }
.range-link:hover { text-decoration-thickness: 2px; }
.range-error { flex-basis: 100%; margin: 0; text-align: right; font-size: 0.84rem; color: var(--red); }

/* The header's flag list (_flag_pop.html): under its button where the browser can anchor it, else centred. */
.flag-pop { inset: 0; margin: auto; inline-size: min(26rem, calc(100vw - 24px)); max-block-size: min(70vh, 32rem);
  overflow: auto; padding: 16px 16px 14px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); font-size: 0.92rem; line-height: 1.4; }
.flag-pop::backdrop { background: rgba(29, 24, 56, 0.2); }
@supports (position-anchor: --a) {
  .pt-flags { anchor-name: --flags; }
  .flag-pop { position-anchor: --flags; inset: auto; top: calc(anchor(bottom) + 8px); left: anchor(left); margin: 0;
    position-try-fallbacks: flip-inline; }
  .flag-pop::backdrop { background: none; }
}
.flag-pop-sub { margin: 0 0 0.6rem; color: var(--ink-2); font-size: 0.84rem; }
.flag-pop-list { list-style: none; display: grid; gap: 2px; margin: 0 -0.4rem; padding: 0; }
.flag-pop-list a { display: grid; grid-template-columns: 1rem minmax(0, 1fr) auto; align-items: baseline;
  gap: 0.15rem 0.5rem; min-height: 40px; padding: 0.45rem 0.4rem; border-radius: 10px; color: var(--ink);
  text-decoration: none; }
.flag-pop-list a:hover { background: var(--surface-2); }
.flag-pop-list a:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.flag-pop-nums { color: var(--ink-2); }
.flag-pop-where { color: var(--accent-ink); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.flag-pop-where::after { content: " ›"; }
.flag-pop-show { margin-top: 0.6rem; }

/* The board beside the side column; the side column under it on narrower screens. */
.pb { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 1.25rem; align-items: start; }
.pb-main { min-width: 0; }
.pb-sub { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.3rem 1rem;
  margin: 0 0 0.6rem; }
.pb-dates { margin: 0; font-size: 0.85rem; line-height: 1.6; color: var(--ink-2); }
.pb-note { margin-inline-start: 0.3rem; }
.pb-note { display: inline-block; padding: 0.05rem 0.6rem; border-radius: 999px; background: var(--navy-tint);
  color: var(--ink-2); font-size: 0.78rem; font-weight: 500; white-space: nowrap; }
/* As many columns as fit: four beside the side column on a laptop, then three, two and one. */
.pb-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.25rem), 1fr)); gap: 0.75rem; }
.pb-empty { grid-column: 1 / -1; margin: 0; padding: 2rem 1rem; border-radius: 14px; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-2); text-align: center; color: var(--ink-2); }
.pb-board-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 1rem;
  margin: 0.75rem 0 0; }
.pb-board-foot .cat-none { margin: 0; }
.pb-days-btn { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 32px; padding: 0 0.2rem;
  margin-inline-start: auto; color: var(--accent-ink); font: 600 0.86rem var(--font-ui); }
.pb-days-btn .icon { width: 16px; height: 16px; }
.pb-days-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* A tile: the name (the button, stretched over the tile), the number, its change, the chart, one line. */
.bt { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 0.75rem 0.9rem 0.7rem;
  border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 3px rgba(25, 20, 48, 0.07);
  transition: box-shadow 0.12s ease-out; }
.bt[hidden] { display: none; }
.bt:has(.bt-open:hover) { box-shadow: inset 0 0 0 1.5px var(--accent), 0 2px 8px rgba(25, 20, 48, 0.1); }
.bt-title { margin: 0; font: 600 0.86rem/1.3 var(--font-ui); letter-spacing: 0; color: var(--ink-2); }
.bt-open { display: inline; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer; }
.bt-open::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: 14px; }
.bt-open:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.bt-open:focus-visible { outline: none; }
.bt-open:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 2px; }
.bt-num { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.1rem 0.5rem;
  margin: 0.2rem 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.2; }
.brief-trend .bt-num { display: block; }
.bt-trend { flex: none; color: var(--ink-2); font-size: 0.74rem; font-weight: 600; white-space: nowrap; }
.bt-num strong { color: var(--ink); font: 700 1.6rem/1.05 var(--font-display); font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.015em; }
.bt-none { color: var(--muted); font: 600 1rem/1.6 var(--font-ui); }
.bt-delta { margin: 0.2rem 0 0; color: var(--ink-2); font-size: 0.78rem; line-height: 1.3; }
.bt-fig { margin: 0.55rem 0 0.3rem; }
.bt-fig svg { display: block; width: 100%; height: auto; }
.bt-foot { margin: auto 0 0; padding-top: 0.25rem; color: var(--muted); font-size: 0.76rem; line-height: 1.3; }
/* A list tile (the nutrient targets): a line per nutrient instead of one number and a chart. */
.bt-rows { list-style: none; display: grid; gap: 0.3rem; margin: 0.45rem 0 0.4rem; padding: 0; font-size: 0.84rem; }
.bt-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 0.5rem; padding-top: 0.3rem;
  border-top: 1px solid var(--line); }
.bt-rows li:first-child { padding-top: 0; border-top: 0; }
.bt-row-label { color: var(--ink-2); }
.bt-rows strong { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.bt-row-target { grid-column: 1 / -1; color: var(--muted); font-size: 0.74rem; }
.bt-row-more { color: var(--muted); font-size: 0.76rem; }
@media (prefers-reduced-motion: reduce) { .bt { transition: none; } }
/* A tile one of the check-in period's flags is about, or a key field off target: the shared soft "off target" look
   (section 8: a very light warm tint and a 3px muted-terracotta bar on the left), and its last lines say which flag
   or key field, with the numbers and a dot (board.Tile.flag_text, key_line), so it's never the colour alone. Forced
   colours get an outline instead (section 8). */
.bt.is-flagged { background: var(--off-tint); box-shadow: inset 3px 0 0 var(--off-line), inset 0 0 0 1px var(--line-2),
  0 1px 3px rgba(25, 20, 48, 0.07); }
.bt.is-flagged:has(.bt-open:hover, .bt-fig-live:hover) { box-shadow: inset 3px 0 0 var(--off-line),
  inset 0 0 0 1.5px var(--accent), 0 2px 8px rgba(25, 20, 48, 0.1); }
.bt-flag { display: flex; align-items: baseline; gap: 0.4rem; margin: 0.5rem -0.9rem -0.7rem;
  padding: 0.45rem 0.9rem 0.55rem; border-radius: 0 0 14px 14px; color: var(--off-ink);
  border-top: 1px solid color-mix(in srgb, var(--off-line) 28%, transparent); font-size: 0.76rem; line-height: 1.35; }
.bt-flag .ico { flex: none; color: var(--off-line); font-size: 0.62rem; }
.bd-flag .ico, .flag-pop .ico { flex: none; color: var(--red); font-size: 0.7rem; }
/* Called up from the header's flag list: a ring that pulses twice. */
.bt.is-called { animation: bt-call 1.2s ease-out 2; }
@keyframes bt-call { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 55%, transparent); }
  100% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--red) 0%, transparent); } }
.bt:target { scroll-margin-block: 6rem; }
.bt.is-flagged:target { box-shadow: inset 4px 0 0 var(--off-line), inset 0 0 0 1.5px var(--off-line); }
@media (prefers-reduced-motion: reduce) {
  .bt.is-called { animation: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 35%, transparent); }
}
/* A tile's chart once app.js reads it: above the tile's stretched button, so the pointer finds its points (a click
   on it still opens the dialog). */
.bt-fig-live { position: relative; z-index: 2; cursor: pointer; }
.bt:has(.bt-fig-live:hover) { box-shadow: inset 0 0 0 1.5px var(--accent), 0 2px 8px rgba(25, 20, 48, 0.1); }

/* The charts (charts.board_chart): the validated series colour, the target dashed, marked days shaded. Blood
   pressure uses the reading chart's two colours, systolic and diastolic. */
.board-chart .grid { stroke: var(--line); stroke-width: 1; }
.board-chart .target { stroke: var(--ink); stroke-width: 1.25; stroke-dasharray: 4 3; opacity: 0.55; }
.board-spark .target { stroke-width: 1; stroke-dasharray: 3 3; }
.board-chart .series { stroke-width: 2; }
.board-spark .series { stroke-width: 1.8; }
.board-chart.bp .series { fill: none; } /* not the reading chart's filled .sys / .dia dots */
.board-chart .series.sys { stroke: var(--macro-carbs); }
.board-chart .series.dia { stroke: var(--macro-protein); }
.board-chart .dot.sys { fill: var(--macro-carbs); }
.board-chart .dot.dia { fill: var(--macro-protein); }
.board-chart .hit:hover { fill: color-mix(in srgb, var(--series-1) 9%, transparent); }
.swatch.bp-sys { background: var(--macro-carbs); }
.swatch.bp-dia { background: var(--macro-protein); }
/* What gives the numbers meaning: the 7-day average over lighter bars (or faint daily dots), the patient's usual
   range and the planned weight rate as soft bands, check-ins sent as a hairline (and a diamond on the axis), the
   check-in period tinted when a flag is about it, and the highest and lowest point labelled in the dialogs. Text in
   text colours; marks in the series colour, the brand's clay for check-ins, red only for what a flag is about. */
.board-chart .bar.soft { opacity: 0.45; }
.board-chart .avg { fill: none; stroke: color-mix(in srgb, var(--series-1) 62%, var(--ink)); stroke-width: 2;
  stroke-linejoin: round; stroke-linecap: round; }
.board-spark .avg { stroke-width: 1.8; }
.board-chart .usual { fill: var(--range-wash); }
.board-chart .cone { fill: color-mix(in srgb, var(--green) 16%, transparent); }
.board-chart .period { fill: color-mix(in srgb, var(--red) 9%, transparent); }
.board-chart .period-label { fill: var(--ink-2); font-size: 10.5px; font-weight: 600; }
.board-chart .checkin { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.8; }
.board-chart .checkin-mark { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.board-chart .ext { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
/* The hover layer (app.js): a light column under a bar, a hairline and rings on a line's points. */
.board-chart .bc-hover { pointer-events: none; }
.board-chart .bc-col { fill: color-mix(in srgb, var(--series-1) 12%, transparent); }
.board-chart:is(.line, .bp) .bc-col, .board-chart:not(.line, .bp) .bc-line { display: none; }
.board-chart .bc-line { stroke: var(--ink-2); stroke-width: 1; opacity: 0.6; }
.board-chart .bc-ring { fill: var(--surface); stroke: var(--series-1); stroke-width: 2; }
.board-chart .bc-ring.avg { stroke: color-mix(in srgb, var(--series-1) 62%, var(--ink)); }
.board-chart.bp .bc-ring { stroke: var(--macro-carbs); }
.board-chart.bp .bc-ring.dia { stroke: var(--macro-protein); }
.board-chart[tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.bc-tip { position: fixed; z-index: 60; min-width: 9.5rem; max-width: min(17rem, calc(100vw - 16px)); margin: 0;
  padding: 0.5rem 0.65rem 0.55rem; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface);
  color: var(--ink); box-shadow: var(--shadow-lg); font: 400 0.8rem/1.35 var(--font-ui); pointer-events: none; }
.bc-tip[hidden] { display: none; }
.bc-tip-day { margin: 0 0 0.3rem; color: var(--ink-2); font-weight: 600; }
.bc-tip-rows { display: grid; gap: 0.15rem; margin: 0; }
.bc-tip-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.bc-tip-row dd { margin: 0; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; }
.bc-tip-row dt { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ink-2); }
.bc-tip-note { margin: 0.3rem 0 0; padding-top: 0.3rem; border-top: 1px solid var(--line); color: var(--ink-2); }
.bc-tip-note.checkin::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 0.4rem 1px 1px;
  background: var(--accent); transform: rotate(45deg); }
/* The chart's key, each with a small copy of its mark (a line key for lines, a box for bars and bands). */
.bd-legend { margin-bottom: 0.4rem; color: var(--ink-2); font-size: 0.8rem; gap: 0.35rem 1rem; }
.bd-key { flex: none; display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.bd-key.bar { background: color-mix(in srgb, var(--series-1) 55%, transparent); }
.bd-key.line { height: 2px; border-radius: 1px; background: var(--series-1); }
.bd-key.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-2); opacity: 0.6; }
.bd-key.avg { height: 2px; border-radius: 1px; background: color-mix(in srgb, var(--series-1) 62%, var(--ink)); }
.bd-key.target { height: 0; border-top: 1.5px dashed color-mix(in srgb, var(--ink) 60%, transparent);
  border-radius: 0; }
.bd-key.usual { background: var(--range-wash); }
.bd-key.cone { background: color-mix(in srgb, var(--green) 22%, transparent); }
.bd-key.period { background: color-mix(in srgb, var(--red) 14%, transparent); }
.bd-key.marked { background: var(--navy-tint); box-shadow: inset 0 0 0 1px var(--line-2); }
.bd-key.checkin { width: 8px; height: 8px; margin: 0 3px; border-radius: 1px; background: var(--accent);
  transform: rotate(45deg); }
.bd-key.bp-sys, .bd-key.bp { height: 2px; background: var(--macro-carbs); }
.bd-key.bp-dia { height: 2px; background: var(--macro-protein); }

/* The side column: sticky beside the board (app.js keeps its lower cards reachable when it's taller than the
   window). The check-in first, then the check-in period, Plan & notes and Devices & apps. */
.pb-rail { position: sticky; top: var(--side-top, 1rem); min-width: 0; }
.pb-rail > .card { margin-bottom: 0.9rem; padding: 1.1rem 1.15rem; }
.pb-rail > details.card.fold:not([open]) { padding-block: 0.9rem; }
.pb-rail .composer h2 { margin-bottom: 0.5rem; }
.pb-rail .composer textarea { min-height: 9rem; max-height: min(42vh, 26rem); }
.cx-when { margin: 0 0 0.7rem; }
.cx-when .pc-priority { margin: 0; font-size: 0.88rem; }
.cx-since { margin: 0.1rem 0 0; font-size: 0.84rem; color: var(--ink-2); }
.cx-period { margin: 0.3rem 0 0; font-size: 0.78rem; line-height: 1.35; color: var(--muted); }
/* "Email it", when they have a saved email: right under Copy & mark sent, as wide; saving and skipping underneath. */
.composer .composer-actions .compose-email { flex: 1 1 100%; padding-block: 0.6rem; }
.composer-more { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; }
.composer-more > p { flex-basis: 100%; margin: 0; }
.composer-more form { margin: 0; }
.pb-period .pw-days { margin-bottom: 0.6rem; }

/* A tile opened large: a native dialog over the page, its heading staying put while the long lists scroll. */
dialog.bd { width: min(62rem, calc(100vw - 2rem)); max-width: none; max-height: min(92vh, 66rem); margin: auto;
  padding: 0; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog.bd-wide { width: min(78rem, calc(100vw - 2rem)); }
dialog.bd::backdrop { background: rgba(15, 13, 31, 0.5); }
.bd-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 1.05rem 1.4rem 0.8rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.bd-titles { min-width: 0; }
.bd-eyebrow { margin: 0 0 0.15rem; color: var(--muted); font: 600 0.7rem/1.2 var(--font-ui); letter-spacing: 0.1em;
  text-transform: uppercase; }
body.portal main .bd-head h2 { margin: 0; font-size: 1.35rem; }
.bd-dates { margin: 0.2rem 0 0; color: var(--ink-2); font-size: 0.84rem; }
.bd-head form { flex: none; margin: 0; }
.bd-body { padding: 1rem 1.4rem 1.5rem; }
.bd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.5rem; margin: 0 0 1rem; }
.bd-stats > div { min-width: 0; padding: 0.55rem 0.75rem; border-radius: 12px; background: var(--surface-2); }
.bd-stats dt { color: var(--ink-2); font-size: 0.76rem; }
.bd-stats dd { margin: 0.1rem 0 0; color: var(--ink); font: 700 1.05rem/1.25 var(--font-display);
  font-variant-numeric: lining-nums tabular-nums; }
.bd-stats.small-stats { margin-bottom: 0.6rem; }
.bd-stat-sub { display: block; margin-top: 0.1rem; color: var(--ink-2); font: 400 0.76rem/1.3 var(--font-ui); }
.bd-trend { color: var(--ink-2); }
/* The check-in period's flags about this measure, first in its dialog, with their Why. */
.bd-flag { margin: 0 0 1rem; padding: 0.7rem 0.9rem 0.75rem; border-radius: 12px; background: var(--red-tint);
  box-shadow: inset 3px 0 0 var(--red); }
.bd-flag-title { display: flex; align-items: baseline; gap: 0.45rem; margin: 0 0 0.35rem; color: var(--ink);
  font-weight: 700; font-size: 0.9rem; }
.bd-flag-list { list-style: none; margin: 0; padding-inline-start: 1.15rem; font-size: 0.88rem; line-height: 1.45; }
.bd-flag-list li + li { margin-top: 0.25rem; }
.bd-flag-why { display: block; color: var(--ink-2); font-size: 0.82rem; }
.bd-flag-sub { margin: 0.4rem 0 0; color: var(--ink-2); font-size: 0.8rem; }
.bd-chart { margin: 0 0 0.25rem; }
.bd-chart .stage-legend { margin-bottom: 0.25rem; }
.bd-chart figcaption { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.bd-h { margin: 1.35rem 0 0.6rem; font-size: 0.98rem; }
.bd-h .muted { font-weight: 400; font-size: 0.82rem; }
.bd-nutrient + .bd-nutrient .bd-h { margin-top: 1rem; }
/* The check-in week's own sections, set apart and named. Their cards sit flat inside the dialog. */
.bd-week { margin-top: 1.5rem; padding-top: 0.9rem; border-top: 1px dashed var(--line-2); }
.bd-week-title { margin: 0; color: var(--muted); font: 600 0.7rem/1.2 var(--font-ui); letter-spacing: 0.1em;
  text-transform: uppercase; }
.bd-body .card { margin: 0.6rem 0 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
body.portal main .bd-body .card > h2 { margin-bottom: 0.6rem; font-size: 1rem; }
.bd-body .card > h2 > .icon { display: none; }
.bd-numbers { margin-top: 1.2rem; }
table.bd-table :is(th, td) { padding: 0.4rem 0.75rem; font-size: 0.86rem; }
table.bd-table tbody th { color: var(--ink); font: 500 0.86rem var(--font-ui); letter-spacing: 0; text-transform: none;
  background: none; white-space: nowrap; }
.bd-list { margin-top: 0; }
@media (prefers-reduced-motion: no-preference) {
  dialog.bd[open] { animation: bd-in 0.16s ease-out; }
  @keyframes bd-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
}

@media (max-width: 1000px) {
  .pb { grid-template-columns: minmax(0, 1fr); }
  .pb-rail { position: static; }
}
@media (max-width: 700px) {
  .pb-controls { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .rangebar { justify-content: flex-start; }
  .range-error { text-align: left; }
  .pb-board { gap: 0.6rem; }
  .pb-days-btn { margin-inline-start: 0; }
  .range-custom input[type=date], .range-form select { font-size: 16px; } /* 16px stops iPhone zooming in */
  dialog.bd, dialog.bd-wide { width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); border-radius: 14px; }
  .bd-head { padding: 0.85rem 1rem 0.7rem; }
  body.portal main .bd-head h2 { font-size: 1.15rem; }
  .bd-body { padding: 0.85rem 1rem 1.2rem; }
  .bd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Check-ins: the same time range, at the end of the summary line. */
.cx-range { margin-inline-start: auto; }
.cx-summary:has(.cx-range) > .help-btn { margin-inline-start: 0; }
@media (max-width: 700px) {
  .cx-range { order: 9; flex-basis: 100%; margin-inline-start: 0; } /* under the counts, which keep their ⓘ */
  .cx-range .rangebar { justify-content: flex-start; }
}

/* The pre-visit brief: the trends over the range as small tiles, two or three to a row on paper. */
.brief-trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: 0.6rem;
  margin: 0.5rem 0 0.75rem; }
.brief-trend .bt-title { font-weight: 650; color: var(--ink); }
@media print {
  .brief-trend { break-inside: avoid; box-shadow: inset 0 0 0 1px #bbb; }
  .brief-trend .bt-num strong { font-size: 1.25rem; }
}

/* ===== end 6 ===== */


/* ===== 7. Billing: the clinic's Billing page, the failed-payment bar, the cap notice, the owner's Billing tab ===== */
/* monitoring/billing.py, billing.html, _owner_billing.html, _cap_full.html. */
.tag.bad { background: var(--red-tint); color: var(--red); }
a.tag { text-decoration: none; }
a.tag:hover { text-decoration: underline; }
.tag.bad .icon { inline-size: 14px; block-size: 14px; }

/* For the clinic's owners while a payment has failed (base.html): below the band, like the view-only note. */
body.portal .billing-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.35rem 0.6rem;
  width: fit-content; max-width: calc(100% - 2rem); margin: 1rem auto 0; padding: 0.45rem 1.1rem; border-radius: 999px;
  background: var(--red-tint); color: var(--ink); font-size: 0.88rem; font-weight: 500;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 40%, transparent); }
body.portal .billing-bar .icon { inline-size: 17px; block-size: 17px; color: var(--red); }
body.portal .billing-bar a { font-weight: 700; }

/* At the plan's patient cap (the invite page) */
.cap-full h2 { margin-block-end: 0.5rem; }
.cap-full p { margin-block: 0 0.6rem; }
.cap-full .actions { margin-block-start: 0.4rem; }
.toast a { font-weight: 700; }

/* The Billing page */
.bill-note { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 1.1rem; padding: 0.75rem 1rem;
  border-radius: 14px; background: var(--surface-2); color: var(--ink); font-weight: 500; }
.bill-note.good { background: var(--green-tint); color: var(--green-ink); }
.bill-note.warn { background: var(--amber-tint); }
.bill-free { margin: 0.6rem 0 0; font-weight: 600; color: var(--ink); }
.bill-note .icon { inline-size: 18px; block-size: 18px; flex: none; }
.bill-failed p { margin-block: 0 0.8rem; }
.bill-off p { margin: 0; color: var(--ink-2); }
.bill-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.9rem; }
.bill-name { margin: 0; font: 600 1.35rem var(--font-display, var(--font-ui)); color: var(--ink); }
.bill-price { margin: 0; font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.bill-price > span:first-child, .bill-plan-price span { color: var(--muted); font-weight: 400; font-size: 0.9em; }
.bill-plan-price span { font-size: 0.62em; }
.bill-head > .tag { margin-inline-start: auto; }
.bill-usage { margin-block: 1rem 0; }
.bill-usage p { margin: 0; }
.bill-usage .meter { block-size: 8px; max-inline-size: 26rem; margin-block: 0.45rem 0.4rem; }
.meter.is-near .fill { background: var(--amber); }
.meter.is-full .fill { background: var(--red); }
.bill-warn { margin: 0.35rem 0 0; color: var(--red); font-weight: 600; }
.bill-facts { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 1rem 0 0; }
.bill-facts dt { font-size: 0.8rem; color: var(--muted); }
.bill-facts dd { margin: 0; font-weight: 600; }
.bill-plans { list-style: none; margin: 0 0 0.9rem; padding: 0; display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); }
.bill-plans li { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; padding: 1rem 1.05rem;
  border: 1px solid var(--line); border-radius: 14px; }
.bill-plans li > :is(form, .tag) { margin-block-start: auto; }
.bill-plans li > form, .bill-plans li > form .btn { inline-size: 100%; }
.bill-plan-price { font-size: 1.5rem; line-height: 1.2; }
.bill-plans li.is-yours { border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent-tint) 60%, transparent); }
.bill-plan-main { display: grid; gap: 0.2rem; min-inline-size: 0; }
.bill-plan-main p { margin: 0; }
.bill-plan-name { font-weight: 700; }
.bill-plan-price { font-weight: 600; }
.bill-email-row { display: flex; gap: 0.6rem; max-inline-size: 30rem; }
.bill-email-row input { flex: 1; min-inline-size: 0; }
.bill-email .errorlist { margin: 0.35rem 0 0; padding: 0; list-style: none; color: var(--red); font-size: 0.85rem; }

/* The owner's Billing tab */
.bill-setup { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0; padding: 0; }
.bill-setup li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.bill-setup code { font-size: 0.8rem; overflow-wrap: anywhere; }
.bill-plan-grid { display: grid; gap: 0; margin-block-end: 0.9rem; }
.bill-plan-row { display: grid; grid-template-columns: minmax(7rem, 1.3fr) minmax(5.5rem, 1fr) minmax(4.5rem, 0.8fr)
  4rem minmax(7.5rem, 1.2fr) auto; align-items: center; gap: 0.5rem 0.75rem; margin: 0; padding: 0.55rem 0;
  border-top: 1px solid var(--line); }
.bill-plan-row.head { padding-block: 0 0.45rem; border-top: 0; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.bill-plan-row input:not([type=checkbox]) { inline-size: 100%; min-inline-size: 0; }
.bill-check { display: flex; align-items: center; gap: 0.4rem; }
.bill-check input { inline-size: 18px; block-size: 18px; margin: 0; }
.bill-stripe { display: grid; gap: 0.15rem; justify-items: start; }
.bill-stripe .small { display: block; }
.bill-sync { margin-block-end: 0.4rem; }
.bill-add { margin-block-start: 0.6rem; }
.bill-add > summary { min-block-size: 24px; font-weight: 600; cursor: pointer; }
.bill-add-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 1rem; margin-block-start: 0.7rem; }
.bill-add-form > div { display: flex; flex-direction: column; gap: 0.3rem; min-inline-size: 0; }
.bill-add-form > .actions { grid-column: 1 / -1; flex-direction: row; }
.bill-clinics { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.bill-clinics > li.card { margin: 0; padding: 1rem 1.15rem; }
.bill-clinics > li.is-failed { border-color: color-mix(in srgb, var(--red) 55%, var(--line));
  box-shadow: inset 4px 0 0 var(--red), var(--shadow); }
.bill-clinic-head { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(12rem, 1fr) auto; align-items: center;
  gap: 0.4rem 1.25rem; }
.bill-clinic-name { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; }
.bill-clinic-use { display: grid; gap: 0.3rem; font-size: 0.9rem; }
.bill-clinic-use .meter { margin: 0; max-inline-size: 14rem; }
.bill-clinic-meta { grid-column: 1 / 3; }
.bill-clinic-meta:empty { display: none; }
.bill-clinic-access { grid-row: 1; grid-column: 3; justify-self: end; }
.bill-clinic-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 0.9rem; margin: 0.85rem 0 0;
  padding-block-start: 0.85rem; border-top: 1px solid var(--line); }
.bill-field { display: flex; flex-direction: column; gap: 0.25rem; min-inline-size: 0; font-size: 0.85rem; }
.bill-field label { font-weight: 600; color: var(--ink-2); }
.bill-field select { max-inline-size: 19rem; }
.bill-field input[type=date] { font: 400 0.95rem var(--font-ui); padding: 0.6rem 0.75rem; border-radius: 12px;
  border: 1px solid var(--field); background: var(--surface); color: var(--ink); }
.bill-field.bill-check { flex-direction: row; align-items: center; min-block-size: 40px; }
.bill-field.bill-narrow input { inline-size: 6.5rem; }
.bill-field.bill-wide { flex: 1 1 13rem; }
.bill-field.bill-wide input { inline-size: 100%; }
.bill-field-note { flex-basis: 100%; margin: 0; }
@media (max-width: 900px) {
  .bill-plan-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bill-plan-row.head { display: none; }
  .bill-clinic-head { grid-template-columns: minmax(0, 1fr) auto; }
  .bill-clinic-use, .bill-clinic-meta { grid-column: 1 / -1; }
  .bill-clinic-access { grid-row: 1; grid-column: 2; }
}
@media (max-width: 600px) {
  .bill-add-form { grid-template-columns: minmax(0, 1fr); }
  .bill-field select, .bill-field input { font-size: 16px; }
}
/* ===== end 7 ===== */


/* ===== 8. Patient types: the board's key section, Check-ins' key fields, the type picker, key fields on the edit
   form, and the Patient types settings page (patient_types.py) ===== */

/* Off target, one soft look for Check-ins' key fields and the board's flagged tiles: a very light warm tint, a 3px
   muted-terracotta bar on the left (3:1 or more against the tint, light and dark) and a small dot with the words
   "Off target" in terracotta ink (AA), so it's never the colour alone, and clearly not a normal tile. */
:root { --off-tint: #fbf3ee; --off-line: #b8735a; --off-ink: #8f4a33; }
@media (prefers-color-scheme: dark) {
  :root { --off-tint: rgba(238, 154, 116, 0.09); --off-line: #c97f61; --off-ink: #f3a582; }
}
.off-dot { display: inline-block; inline-size: 6px; block-size: 6px; margin-inline-end: 0.3rem; border-radius: 50%;
  background: var(--off-line); vertical-align: 1px; }

/* Check-ins: a card's key fields, value against target. Five columns on every card, so they line up down the list;
   one off target in the soft look above, saying "Off target" in words. */
.pc-keys { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pc-tile.is-off { background: var(--off-tint); box-shadow: inset 3px 0 0 var(--off-line), inset 0 0 0 1px var(--line); }
.pc-off { color: var(--off-ink); font-weight: 600; white-space: nowrap; }
.pc.is-done .pc-keys { opacity: 0.8; }
@media (max-width: 1200px) { .pc-keys { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); } }
@media (max-width: 700px) { .pc-keys { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (forced-colors: active) { .pc-tile.is-off, .bt.is-flagged { outline: 2px solid CanvasText; outline-offset: -2px; } }
/* A card's name line: a small quiet chip with their priority when the list isn't in priority sections, and under the
   type, "Last data Nov 23" once the newest data is more than 2 days old (an amber dot from 7). */
.pc-chip { position: relative; z-index: 2; display: inline-block; margin-inline-start: 0.35rem; padding: 0.02rem 0.45rem;
  border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-2);
  font: 600 0.7rem/1.5 var(--font-ui); vertical-align: 2px; cursor: default; }
.pc-chip.is-high { color: var(--ink); box-shadow: inset 0 0 0 1px var(--off-line); }
.pc-id .pc-name { display: inline; }
.pc-last { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.1rem; font-size: 0.76rem; color: var(--muted); }
.pc-dot { flex: none; inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--amber); }

/* The patient board: the type's key fields first, in a quietly separated section labelled with the type. */
.pb-key { margin: 0 0 1.1rem; padding: 0.8rem 0.85rem 0.85rem; border-radius: 18px; background: var(--wash);
  box-shadow: inset 0 0 0 1px var(--line); }
.pb-key-head { margin: 0 0 0.65rem; color: var(--ink); font: 650 0.95rem/1.3 var(--font-display); letter-spacing: -0.01em; }
.pb-key-head .muted { font: 400 0.8rem var(--font-ui); letter-spacing: 0; }
.pb-key-head a { color: var(--accent-ink); }
.pb-key:not(:has(.bt:not([hidden]))) { display: none; } /* every key tile filtered out by a chip */
.bt-key { margin: 0.35rem 0 0; color: var(--ink-2); font-size: 0.76rem; line-height: 1.35; }
/* A tile can say two things in red: its key field off target, and a check-in period flag about it. */
.bt-flag-group { margin: 0.5rem -0.9rem -0.7rem; border-radius: 0 0 14px 14px; overflow: hidden;
  border-top: 1px solid color-mix(in srgb, var(--off-line) 28%, transparent); }
.bt-flag-group .bt-flag { margin: 0; border-radius: 0; border-top: 0; background: none; }
.bt-flag-group .bt-flag + .bt-flag { border-top: 1px solid color-mix(in srgb, var(--off-line) 22%, transparent); }
.bd-keyfield.is-on { background: var(--surface-2); }
.bd-key-line { margin: 0.25rem 0 0; font-size: 0.9rem; line-height: 1.45; color: var(--ink); }

/* Add a patient: the types as a compact list of choices, each with its one line. */
.pt-types { border: 0; margin: 1.1rem 0 0.9rem; padding: 0; min-width: 0; }
.pt-types > legend { padding: 0; margin: 0 0 0.2rem; font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.pt-types > .pf-hint { margin: 0 0 0.55rem; }
.pt-type-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; margin: 0; padding: 0;
  list-style: none; }
.pt-type { position: relative; display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.55rem 0.75rem;
  border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); cursor: pointer; }
.pt-type:has(input:checked) { background: var(--accent-tint); box-shadow: inset 0 0 0 2px var(--accent); }
.pt-type:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.pt-type input { flex: none; margin: 0.2rem 0 0; width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.pt-type-name { display: block; font-weight: 600; font-size: 0.9rem; line-height: 1.3; color: var(--ink); }
.pt-type-sum { display: block; margin-top: 0.1rem; font-size: 0.77rem; line-height: 1.35; color: var(--muted); }
.pt-type-tag { margin-inline-start: 0.3rem; font-size: 0.68rem; padding: 0.02rem 0.4rem; vertical-align: 1px; }
@media (max-width: 700px) { .pt-type-list { grid-template-columns: minmax(0, 1fr); } }

/* The edit form: what changing the type will change, and the key fields with their tolerance and window. */
.pf-type-changes { margin: 0.9rem 0 0; padding: 0.75rem 0.9rem; border-radius: 12px; background: var(--navy-tint);
  font-size: 0.88rem; }
.pf-type-changes h3 { margin: 0 0 0.3rem; font: 650 0.9rem var(--font-ui); }
.pf-type-changes ul { margin: 0.2rem 0 0.3rem; padding-left: 1.1rem; }
.pf-type-changes p { margin: 0.2rem 0 0; color: var(--ink-2); }
.kf-wrap { overflow-x: auto; }
/* Like the nutrients table: plain row names (not the app's uppercase headers), one line of boxes per key field. */
.kf-table { width: 100%; border-collapse: collapse; }
.kf-table :is(th, td) { padding: 0.5rem 0.9rem 0.5rem 0; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--line); background: none; }
.kf-table thead th { padding-block: 0.1rem 0.4rem; font: 600 0.72rem var(--font-ui); letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.kf-table tbody tr:last-child > * { border-bottom: 0; }
.kf-table tbody th { width: 28%; min-width: 9rem; font: 600 0.92rem/1.35 var(--font-ui); letter-spacing: 0;
  text-transform: none; color: var(--ink); white-space: normal; }
.kf-name-sub { display: block; margin-top: 0.15rem; font-size: 0.76rem; font-weight: 400; color: var(--muted); }
.kf-tol { display: flex; flex-wrap: nowrap; align-items: center; gap: 0.4rem; }
.kf-table select { width: auto; min-width: 0; }
.kf-table :is(select, input) { min-height: 36px; padding-block: 0.3rem; padding-inline-start: 0.6rem; font-size: 0.9rem; }
.kf-tol input { width: 4.6rem; min-width: 0; padding-inline-end: 0.4rem; }
.kf-win { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; }
.kf-win .kf-reset { min-block-size: 24px; padding: 0.1rem 0.5rem; font-size: 0.8rem; }
.kf-unit { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.kf-changed { font-size: 0.68rem; padding: 0.02rem 0.45rem; }
.kf-hint { margin: 0 0 0.4rem; }
/* The second box only for "between" (a browser without :has() shows neither, and the first number alone applies). */
.kf-to { display: none; align-items: center; gap: 0.35rem; }
.kf-tol:has(option[value="between"]:checked) .kf-to { display: inline-flex; }
.kf-table .errorlist { margin: 0.25rem 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--red); }
.kf-reset { white-space: nowrap; }
/* Add a key number for this patient (board_layout.py): a measure, its button and one line. */
.kf-add { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem 0.6rem; margin: 0.7rem 0 0; }
.kf-add select { width: auto; min-width: 12rem; min-height: 36px; padding-block: 0.3rem; font-size: 0.9rem; }
.kf-add .btn .icon { width: 15px; height: 15px; }
.kf-add .pf-hint { flex-basis: 100%; }

/* Settings: Patient types. Built-in types read-only with "Make a copy"; the clinic's own with Edit and Delete. */
.tt-section { margin: 0 0 1.6rem; }
.tt-section > h2 { margin: 0 0 0.25rem; font: 650 1.05rem/1.3 var(--font-display); color: var(--ink); }
.tt-section > p { margin: 0 0 0.75rem; color: var(--ink-2); font-size: 0.88rem; }
.tt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.tt { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 1rem; align-items: start; margin: 0;
  padding: 0.85rem 1rem; border-radius: 14px; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 3px rgba(25, 20, 48, 0.07); }
.tt-name { margin: 0; font: 650 1rem/1.3 var(--font-ui); color: var(--ink); }
.tt-name .muted { font-weight: 400; font-size: 0.82rem; }
.tt-sum { margin: 0.15rem 0 0; font-size: 0.85rem; color: var(--ink-2); }
.tt-keys { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.45rem 0 0; padding: 0; list-style: none; }
.tt-keys li { padding: 0.12rem 0.55rem; border-radius: 999px; background: var(--surface-2); font-size: 0.76rem;
  color: var(--ink-2); }
.tt-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; align-items: flex-start; }
.tt-actions form { margin: 0; }
.tt-delete > summary { list-style: none; }
.tt-delete > summary::-webkit-details-marker { display: none; }
.tt-delete-body { margin-top: 0.5rem; padding: 0.7rem 0.8rem; border-radius: 12px; background: var(--red-tint);
  font-size: 0.86rem; max-width: 22rem; }
.tt-delete-body p { margin: 0 0 0.5rem; }
.tt-form-keys .kf-table select[name$="_metric"] { max-width: 13rem; }
.tt-protocol { margin-top: 1rem; }

/* The pre-visit brief's key fields: one line each, off target in words. */
.brief-keys { margin: 1rem 0 0; }
.brief-keys h3 { margin: 0 0 0.35rem; font: 650 0.95rem/1.3 var(--font-ui); }
.brief-keys h3 .muted { font-weight: 400; font-size: 0.82rem; }
.brief-key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; font-size: 0.88rem; }
.brief-key-list li.is-off { padding-left: 0.5rem; border-left: 3px solid var(--red); }
.brief-off { color: var(--red); }
@media (max-width: 700px) { .tt { grid-template-columns: minmax(0, 1fr); } .tt-actions { justify-content: flex-start; } }
/* ===== end 8 ===== */

/* ===== Check-ins sent to the app, and the record of every one sent (sent_messages.py, records.py) ===== */
.cx-app-line { display: flex; gap: 0.45rem; align-items: flex-start; margin: 0.6rem 0 0; padding: 0.55rem 0.75rem;
  border-radius: 12px; background: var(--navy-tint); font-size: 0.85rem; color: var(--ink); }
.cx-app-line .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--dusk-ink); }
.cx-sent { margin: 0.25rem 0 0.75rem; }
.cx-sent-how { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0 0 0.3rem;
  font: 600 0.9rem/1.4 var(--font-ui); }
.cx-sent-how .icon { width: 16px; height: 16px; color: var(--green-ink); }
.cx-sent-how .muted { font-weight: 400; }
.cx-sent-state { margin: 0 0 0.6rem; font-size: 0.84rem; color: var(--ink-2); }
.cx-sent-state .tag { margin-right: 0.2rem; }
.cx-sent-text { margin: 0 0 0.6rem; padding: 0.85rem 1rem; border-radius: 12px; background: var(--surface-2);
  font-size: 0.95rem; line-height: 1.55; overflow-wrap: anywhere; }
.cx-sent-foot { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; }
.cx-sent-foot p { margin: 0; flex: 1 1 14rem; }
.cx-again { margin: 0.75rem 0 0; }
.cx-again > summary { list-style: none; cursor: pointer; }
.cx-again > summary::-webkit-details-marker { display: none; }
.cx-again[open] > summary { margin-bottom: 0.5rem; }
.peek-note { display: flex; gap: 0.4rem; align-items: flex-start; margin: -0.5rem 0 0.9rem; font-size: 0.82rem;
  color: var(--ink-2); }
.peek-note .icon { width: 15px; height: 15px; flex: none; margin-top: 2px; }
/* Settings → Sent messages (records.py) */
.rec-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.6rem; margin: 0 0 1rem; }
.rec-facts div { padding: 0.7rem 0.85rem; border-radius: 12px; background: var(--surface-2); }
.rec-facts dt { font-size: 0.78rem; color: var(--ink-2); }
.rec-facts dd { margin: 0.15rem 0 0; font: 650 1.15rem/1.2 var(--font-ui); }
.rec-export { display: grid; gap: 0.6rem; max-width: 26rem; }
.rec-export input[type="password"] { width: 100%; }
.rec-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; font-size: 0.88rem; }
.rec-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.15rem 0.75rem; padding: 0.6rem 0.75rem;
  border-radius: 12px; background: var(--surface-2); }
.rec-list .rec-text { grid-column: 1 / -1; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
/* Save to chart (chart.py): the brief's document, a message after another, each exactly as sent */
.chart-controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem 1.5rem;
  margin-bottom: 1rem; }
.chart-range { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; }
.chart-range fieldset { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.1rem; border: 0; margin: 0;
  padding: 0; }
.chart-range legend { float: left; margin-right: 0.4rem; font-weight: 600; font-size: 0.9rem; }
.chart-range label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; }
.chart-range input[type="date"] { padding: 0.25rem 0.45rem; }
.chart-last { display: flex; gap: 0.4rem; align-items: flex-start; margin: 0; font-size: 0.86rem; color: var(--ink-2); }
.chart-last .icon { width: 16px; height: 16px; color: var(--green-ink); flex: none; margin-top: 2px; }
.chart-actions form { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chart-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.9rem; }
.chart-item { padding: 0 0 0.9rem; border-bottom: 1px solid var(--line); }
.chart-item:last-child { border-bottom: 0; }
.chart-when { margin: 0 0 0.3rem; font-size: 0.9rem; }
.chart-when span { color: var(--ink-2); }
.chart-focus { margin: 0 0 0.35rem; font-size: 0.88rem; }
.chart-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 0.7rem 0.95rem;
  border-left: 3px solid var(--line-2); background: var(--surface-2); border-radius: 0 12px 12px 0; font-size: 0.92rem;
  line-height: 1.5; }
.chart-empty { margin: 1rem 0; color: var(--ink-2); }
.chart-foot { margin-top: 1.2rem; padding-top: 0.6rem; border-top: 1px solid var(--line); font-size: 0.8rem;
  color: var(--muted); }
@media print {
  .chart-item { break-inside: avoid; }
  .chart-text { font-size: 9.5pt; }
  .chart-when, .chart-focus { font-size: 9.5pt; }
  .chart-foot { font-size: 8pt; }
}
/* ===== end sent messages ===== */


/* ===== 9. Arrange the patient board (board_layout.py, board-arrange.js) ===== */
/* "Arrange" puts the board in a quiet moving state: each tile gets a dashed outline, a grab cursor and its own small
   buttons in its top corner (earlier, later, − or +), and a bar above the board says what's happening, who set the
   layout, and offers Reset to type and Done. A tile being dragged lifts (a shadow, a touch larger). One gentle sway as
   it starts, only for those who haven't asked for less motion. The tile's dialog and chart don't answer the pointer
   meanwhile. */
.pb-arrange-btn { margin-inline-start: auto; }
.pb-arrange-btn .icon { width: 16px; height: 16px; }
.pb-arrbar { position: sticky; top: 0.5rem; z-index: 6; display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: 0.6rem 1.25rem; margin: 0 0 0.9rem; padding: 0.75rem 0.95rem;
  border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent), var(--shadow); }
.pb-arrbar[hidden] { display: none; }
.pb-arr-text { flex: 1 1 22rem; min-width: 0; }
.pb-arr-title { display: flex; align-items: center; gap: 0.45rem; margin: 0; color: var(--ink);
  font: 650 0.95rem/1.3 var(--font-display); letter-spacing: -0.01em; }
.pb-arr-title .icon { width: 17px; height: 17px; color: var(--accent-ink); }
.pb-arr-help { margin: 0.25rem 0 0; font-size: 0.84rem; line-height: 1.45; color: var(--ink-2); text-wrap: pretty; }
.pb-arr-note { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--muted); }
.pb-arr-status { flex-basis: 100%; margin: 0; font-size: 0.8rem; color: var(--ink-2); }
.pb-arr-status:empty { display: none; }
.pb-arr-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.5rem; }
.pb-arr-more { position: relative; }
.pb-arr-more > summary { list-style: none; }
.pb-arr-more > summary::-webkit-details-marker { display: none; }
.pb-arr-more .icon { width: 15px; height: 15px; }
.pb-arr-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 7; display: grid; gap: 0.4rem;
  inline-size: max-content; max-inline-size: min(20rem, 80vw); padding: 0.75rem; border-radius: 14px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-lg); }
.pb-arr-menu p { margin: 0 0 0.2rem; }
.pb-arr-menu .btn { justify-content: flex-start; }

.pb-board[data-list] { position: relative; } /* the tiles' positions are measured from their own list */
.bt-arr { display: none; }
.is-arranging .bt-arr { position: absolute; top: 0.4rem; right: 0.4rem; z-index: 3; display: flex; gap: 0.2rem; }
.bt-arr-btn { display: inline-grid; place-items: center; inline-size: 30px; block-size: 30px; margin: 0; padding: 0;
  border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink-2);
  cursor: pointer; }
.bt-arr-btn .icon { width: 15px; height: 15px; }
.bt-arr-btn:hover:not(:disabled) { background: var(--accent-tint); color: var(--accent-ink); border-color: transparent; }
.bt-arr-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.bt-arr-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bt-arr-pin { margin-inline-start: 0.15rem; }
.is-arranging .bt-title { padding-inline-end: 6.6rem; } /* the name never runs under the buttons */
.is-arranging .pb-board .bt { cursor: grab; touch-action: pan-y; box-shadow: inset 0 0 0 1.5px var(--line-2);
  outline: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: -5px; }
.is-arranging .bt-open::after { cursor: grab; }
.is-arranging .bt-open:hover { color: inherit; text-decoration: none; }
.is-arranging .bt:has(.bt-open:hover) { box-shadow: inset 0 0 0 1.5px var(--line-2); }
.is-arranging .bt-fig, .is-arranging .bt-fig-live { pointer-events: none; }
.bt.is-pressing { box-shadow: inset 0 0 0 1.5px var(--accent), 0 2px 8px rgba(25, 20, 48, 0.12); }
.pb-board .bt.is-lift { z-index: 5; cursor: grabbing; box-shadow: inset 0 0 0 1.5px var(--accent),
  0 14px 32px rgba(25, 20, 48, 0.22); }
@media (prefers-reduced-motion: no-preference) {
  .pb-board .bt.is-lift { scale: 1.02; }
  /* One gentle sway as arrange mode starts, then still: a tile's buttons never move under the pointer. */
  .is-arranging .pb-board .bt:not(.is-lift) { animation: bt-sway 0.5s ease-in-out 2; }
  .is-arranging .pb-board .bt:nth-child(2n):not(.is-lift) { animation-delay: 0.08s; }
}
@keyframes bt-sway { 0%, 100% { rotate: 0deg; } 25% { rotate: -0.4deg; } 75% { rotate: 0.4deg; } }
@media (max-width: 700px) {
  .pb-arrbar { top: 0.25rem; padding: 0.65rem 0.75rem; }
  .pb-arr-actions { justify-content: flex-start; }
}
@media (forced-colors: active) {
  .is-arranging .pb-board .bt { outline: 2px dashed CanvasText; }
  .bt-arr-btn { border-color: ButtonText; }
}
@media print { .pb-arrbar, .bt-arr, .pb-arrange-btn { display: none !important; } }

/* --- 9b. The filter and sort bar on Check-ins and the Patients list (list_bar.py, _list_bar.html) -------------------
   One quiet row of pills, as the practitioner filter was: each filter shows its name and what's chosen ("Type · All
   types"), a chosen one in the accent's tint; a pill opens a short menu of ticks under it. The sort sits at the end.
   Under it, "Showing 6 of 24" and Clear. */
.lb { margin: 0 0 1rem; }
.lb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.lb-pick { position: relative; }
.lb-pick > summary { list-style: none; }
.lb-pick > summary::-webkit-details-marker { display: none; }
.lb-btn, .lb-select, .lb-check { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 36px;
  padding: 0.3rem 0.85rem; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font: 500 0.86rem/1.2 var(--font-ui); cursor: pointer; }
.lb-btn::after { content: ""; inline-size: 0.42rem; block-size: 0.42rem; margin-inline-start: 0.1rem;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; rotate: 45deg; translate: 0 -2px;
  opacity: 0.7; }
.lb-pick[open] > .lb-btn::after { rotate: 225deg; translate: 0 2px; }
.lb-btn:hover, .lb-select:hover, .lb-check:hover { background: var(--surface-2); color: var(--ink); }
.lb-btn:focus-visible, .lb-check:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.lb-name { color: var(--muted); font-weight: 500; }
.lb-val { color: var(--ink); font-weight: 600; }
.lb .is-on { border-color: transparent; background: var(--accent-tint); color: var(--accent-ink); }
.lb .is-on .lb-name { color: var(--accent-ink); }
.lb .is-on .lb-val { color: var(--accent-ink); }
.lb-select { padding-block: 0.15rem; padding-inline-end: 0.35rem; cursor: default; }
.lb .lb-select select { width: auto; min-width: 0; min-height: 30px; margin: 0; padding: 0.15rem 1.8rem 0.15rem 0.55rem; border: 0;
  background-color: transparent; color: var(--ink); font: 600 0.86rem var(--font-ui); }
.lb .is-on select { color: var(--accent-ink); }
.lb-select select:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-radius: 8px; }
.lb-sort { margin-inline-start: auto; }
.lb-sort .icon { width: 15px; height: 15px; color: var(--muted); }
.lb-check input { margin: 0; width: 1rem; height: 1rem; accent-color: var(--accent); }
.lb-check:has(input:checked) { color: var(--ink); }
.lb-menu { position: absolute; left: 0; top: calc(100% + 6px); z-index: 8; display: grid; gap: 0.1rem;
  inline-size: max-content; min-inline-size: 13rem; max-inline-size: min(22rem, calc(100vw - 2rem)); margin: 0;
  padding: 0.45rem; border: 0; border-radius: 14px; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-lg); }
.lb-opt { display: flex; align-items: center; gap: 0.55rem; min-height: 36px; padding: 0.3rem 0.55rem;
  border-radius: 9px; color: var(--ink); font-size: 0.88rem; cursor: pointer; }
.lb-opt:hover { background: var(--surface-2); }
.lb-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.lb-opt input { flex: none; margin: 0; width: 1rem; height: 1rem; accent-color: var(--accent); }
.lb-opt > span:first-of-type { flex: 1; }
.lb-count { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.lb-menu-note { max-inline-size: 19rem; margin: 0.3rem 0.55rem 0.2rem; color: var(--muted); font-size: 0.76rem;
  line-height: 1.35; }
.lb-summary { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.84rem; }
.lb-summary a { color: var(--accent-ink); font-weight: 600; }
.lb-apply[hidden] { display: none; }
/* Check-ins sorted by patient type: a small heading per type. The Patients list's type headings, as a table row. */
.pc-group > .group-head.is-small { margin-bottom: 0.5rem; font-size: 0.92rem; }
.pc-group > .group-head.is-small .tile-icon { width: 24px; height: 24px; border-radius: 8px; }
.pc-group > .group-head.is-small .tile-icon .icon { width: 13px; height: 13px; }
table.patient-list .pl-group th { padding: 1rem 0.5rem 0.4rem; border: 0; background: none; color: var(--ink);
  font: 650 0.9rem/1.3 var(--font-display); letter-spacing: -0.01em; text-align: left; }
table.patient-list .pl-group th .muted { font: 400 0.82rem var(--font-ui); }
@media (max-width: 700px) {
  .lb-sort { margin-inline-start: 0; }
  .lb-pick[open] { flex-basis: 100%; }  /* on a phone a menu opens in place, under its pill */
  .lb-menu { position: static; margin-top: 0.4rem; inline-size: auto; max-inline-size: none; }
  table.cards.patient-list tr.pl-group { padding: 0.6rem 0 0.2rem; background: none; box-shadow: none; }
}
@media (forced-colors: active) { .lb .is-on { border: 2px solid Highlight; } }
/* ===== end 9 ===== */
