/*
 * RxChange styles — themed after Mundana (codebygina/mundana-theme-jekyll).
 *
 * Mundana is an editorial theme: Medium-green accent, Georgia display headings at
 * regular weight, hairline borders, generous whitespace, white chrome. Those are
 * the parts adopted here.
 *
 * What is deliberately NOT adopted is its body copy: 20px Lora at 1.86 line-height
 * is lovely for an article and unusable for a nine-column inventory table. So
 * prose and headings carry the theme's voice, while tabular data stays in a tight
 * sans with tabular numerals. A pharmacist scanning 1,400 rows for a drug name
 * needs density, not leading.
 *
 * Lora is self-hosted rather than linked from Google. That keeps the CSP at
 * font-src 'self' and stops a healthcare app making a third-party request on every
 * page load. It is one variable file covering 400-700.
 *
 * One stylesheet, no build step — which is what makes a nonce-based CSP with no
 * 'unsafe-inline' achievable.
 */

/* --- Fonts ---------------------------------------------------------------- */

@font-face {
  font-family: 'Lora';
  src: url('/assets/fonts/lora-variable.woff2') format('woff2-variations'),
       url('/assets/fonts/lora-variable.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Lora';
  src: url('/assets/fonts/lora-variable-italic.woff2') format('woff2-variations'),
       url('/assets/fonts/lora-variable-italic.woff2') format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

/* --- Tokens --------------------------------------------------------------- */

:root {
  /* Mundana's shape and spacing, but the accent is taken from the RxChange mark
     itself (#169A76) so the logo and the interface are the same green rather than
     two greens a shade apart. The mark's blue is kept for secondary emphasis. */
  --accent: #169a76;
  --accent-hover: #117a5d;
  --accent-soft: #e6f3ee;
  --brand-blue: #3b78a8;
  --accent-ink: #ffffff;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --border: #e6e6e6;
  --border-strong: #ced4da;

  --text: #212529;
  --text-muted: #6c757d;
  --text-faint: #9aa1a8;

  --ok: #169a76;
  --ok-soft: #e6f3ee;
  --warn: #a97400;
  --warn-soft: #fff6df;
  --danger: #d3244f;
  --danger-soft: #fdeaef;
  --info: #1c7ed6;
  --info-soft: #e7f2fd;

  --radius: 4px;
  --radius-sm: 4px;
  --radius-pill: 30px;
  --shadow: none;
  --shadow-raised: 0 1px 3px rgba(0, 0, 0, 0.06);

  --serif: Georgia, "Times New Roman", Times, serif;
  --prose: 'Lora', Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* The green lifts to stay legible on a dark ground; everything else inverts
       around the same neutral ramp so the theme still reads as itself. */
    --accent: #3fce9f;
    --accent-hover: #62dcb3;
    --accent-soft: #10312a;
    --brand-blue: #6fa8d4;
    --accent-ink: #08201a;

    --bg: #16181c;
    --surface: #1d2025;
    --surface-2: #24272d;
    --border: #31353c;
    --border-strong: #454a53;

    --text: #e8eaed;
    --text-muted: #a5acb5;
    --text-faint: #7c838c;

    --ok: #3fce9f;
    --ok-soft: #10312a;
    --warn: #e0aa47;
    --warn-soft: #33280f;
    --danger: #f4718f;
    --danger-soft: #35161f;
    --info: #63aef0;
    --info-soft: #12283c;

    --shadow-raised: 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/*
 * Headings are Georgia at regular weight, which is Mundana's most recognisable
 * signature — its headlines are large and serif but never bold.
 */
h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
  color: var(--text);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

code, .mono { font-family: var(--mono); font-size: 0.88em; }

/* Prose passages — the one place Lora is used, as the theme intends. */
.prose { font-family: var(--prose); font-size: 1.02rem; line-height: 1.75; }

/* --- Top bar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  /* Wraps to a second line on a phone rather than pushing content off-screen. */
  flex-wrap: wrap;
}

.brand {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  margin-right: 0.75rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.brand:hover { text-decoration: none; color: var(--text); }
/* Only the accented half is green. The wordmark is one flex child so the gap
   applies between the mark and the text, not inside "RxChange". */
.brand-word { white-space: nowrap; }
.brand-accent { color: var(--accent); }
.brand-mark { display: block; width: 34px; height: 34px; flex: none; }
@media (max-width: 640px) { .brand-mark { width: 28px; height: 28px; } }

.nav { display: flex; gap: 0.15rem; flex: 1 1 auto; flex-wrap: wrap; min-width: 0; }

.nav a {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.95rem;
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
  /* min-width:0 lets this shrink instead of forcing the bar wider than the
     window, which is what pushed "Sign out" off the edge on a phone. */
  min-width: 0;
}
.topbar-right form { display: flex; }
/* Wide enough for a real pharmacy name — "Hurricane Family Pharmacy" was being
   clipped mid-word, which looks like a rendering fault rather than a long name. */
.topbar-right select {
  max-width: 19rem;
  font-size: 0.88rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-pill);
}

.who { color: var(--text-muted); text-align: right; line-height: 1.25; min-width: 0; }
.who strong {
  display: block;
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* On a phone the identity block is noise; the nav and controls are what matter. */
@media (max-width: 640px) {
  .topbar { padding: 0.5rem 1rem; gap: 0.5rem; }
  .brand { font-size: 1.25rem; }
  .nav { order: 3; flex-basis: 100%; }
  .topbar-right { margin-left: auto; }
  .who { display: none; }
  .topbar-right select { max-width: 9rem; }
}

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

/*
 * The layout renders <div id="main" class="main">, so these must be CLASS
 * selectors. An element selector `main {}` matches nothing here, which silently
 * dropped the max-width and the side padding and let every table run to the
 * window edge. The bare element is kept alongside in case the markup ever becomes
 * a real <main>.
 */
main,
.main   { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem 5rem; }
/* Data-dense pages: nine columns read badly when squeezed. */
.wide   { max-width: 1760px; margin: 0 auto; padding: 2rem 1.5rem 5rem; }
.narrow { max-width: 440px;  margin: 3.5rem auto; padding: 0 1.5rem 5rem; }
.medium { max-width: 760px;  margin: 0 auto; padding: 2rem 1.5rem 5rem; }

@media (max-width: 640px) {
  main, .main, .wide, .medium { padding: 1.25rem 1rem 4rem; }
  .narrow { margin: 1.5rem auto; padding: 0 1rem 4rem; }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { margin-bottom: 0.25rem; }
/* A standing statement of fact, not a warning.
   Rules that are permanently true and need no action on this page get this
   muted line rather than a .notice. A .notice that is on screen every visit
   stops registering, and takes the ones that do need action down with it. */
.page-head .page-note {
  margin: 0.45rem 0 0;
  font-size: 0.83rem;
  color: var(--text-faint);
}
.page-head p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

/* --- Cards ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card > :last-child { margin-bottom: 0; }
.card-head { margin: 0 0 1.25rem; }
.card-head h2 { margin-bottom: 0.2rem; }
.card-head p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }

/* Sort pills.
 *
 * The shape is .btn's, unchanged -- these are the same pill the rest of the app
 * uses, so only the selected state needs saying. Built from the accent tokens
 * rather than fixed colours so the dark theme follows without a second rule. */
.sort-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}
.sort-pills > .faint { margin-right: 0.15rem; }
.sort-pill.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.grid { display: grid; gap: 1.5rem; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* --- Forms ---------------------------------------------------------------- */

.field { margin-bottom: 1.15rem; }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  margin-bottom: 0.35rem;
  color: var(--text);
}
.hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-top: 0.35rem;
}

/*
 * Every text-like input, including ones written WITHOUT a type attribute.
 *
 * `input[type="text"]` matches a literal attribute, not an effective type, so
 * `<input name="code">` matched nothing and fell back to the raw browser box —
 * 179px wide with 1px padding and square corners, next to themed fields at 662px.
 * Excluding by type is the resilient direction: a new field is styled by default
 * rather than only if someone remembers the attribute.
 */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not([type="range"]):not([type="color"]):not([type="hidden"]),
select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  /* Pinned so an <input> and a <select> come out the same height. Left to the
     browser they differ by about 4px, which reads as a misaligned row. The
     min-height then removes the last pixel of sub-pixel rounding between them. */
  line-height: 1.4;
  min-height: 2.6rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[readonly], input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
}
textarea { min-height: 5.5rem; resize: vertical; line-height: 1.6; }

/*
 * Field widths.
 *
 * A full-width input tells the reader "type a lot here". For a six-digit code or
 * a three-letter store code that is simply wrong, and it looks unconsidered. These
 * cap the width while staying fluid below it, so nothing overflows on a phone.
 */
.input-code {
  width: 100%;
  max-width: 9.5em;
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  /* Letter-spacing adds a trailing gap after the last character, which pulls the
     text off-centre. Indenting by the same amount puts it back. */
  text-indent: 0.32em;
  text-align: center;
  padding: 0.6rem 0.5rem;
}
.input-code::placeholder { letter-spacing: 0.32em; font-weight: 400; opacity: 0.35; }

.input-recovery {
  width: 100%;
  max-width: 15em;
  font-family: var(--mono);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}
.input-recovery::placeholder { text-transform: none; letter-spacing: 0.04em; opacity: 0.4; }

/* Short identifiers: a store code, an NCPDP, a DEA number, a file glob. */
.input-short { width: 100%; max-width: 11em; }
.input-mid   { width: 100%; max-width: 22em; }
.input-qty   { width: 100%; max-width: 9em; font-variant-numeric: tabular-nums; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1 1 12rem; min-width: 0; }

.check { display: flex; align-items: flex-start; gap: 0.5rem; }
.check input { width: auto; margin-top: 0.2rem; accent-color: var(--accent); }
.check label { font-weight: 400; margin: 0; font-size: 0.92rem; }

/* --- Buttons -------------------------------------------------------------- */

/* Mundana's buttons are pill-shaped; that shape is most of its personality. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 1.2rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}

.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.28rem 0.85rem; font-size: 0.84rem; }
/* For several actions sitting inside one table row, where a normal small button
   is heavier than the text it sits beside. */
.btn-xs {
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
}

.actions { display: flex; gap: 0.65rem; flex-wrap: wrap; margin-top: 1.5rem; align-items: center; }
.actions-end { justify-content: flex-end; }

/* --- Notices -------------------------------------------------------------- */

.notice {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid;
  border-left-width: 3px;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
  line-height: 1.55;
}
.notice p { margin: 0 0 0.4rem; }
.notice > :last-child { margin-bottom: 0; }
.notice-ok    { background: var(--ok-soft);     border-color: var(--ok);     color: var(--ok); }
.notice-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.notice-info  { background: var(--info-soft);   border-color: var(--info);   color: var(--info); }
.notice-warn  { background: var(--warn-soft);   border-color: var(--warn);   color: var(--warn); }
.notice strong { color: inherit; font-weight: 700; }

/* --- Tables --------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 1.5rem;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

th, td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  background: var(--surface-2);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}
th a { color: inherit; display: inline-flex; gap: 0.25rem; }
th a:hover { color: var(--accent); text-decoration: none; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
/* Tabular numerals keep quantities and prices aligned down the column. */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.empty { padding: 3rem 1rem; text-align: center; color: var(--text-muted); }
.empty strong { color: var(--text); font-family: var(--serif); font-weight: 400; font-size: 1.1rem; }

/* --- Badges --------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.5;
}
.badge-plain  { color: var(--text-muted); border-color: var(--border-strong); }
.badge-info   { color: var(--info);   border-color: var(--info);   background: var(--info-soft); }
.badge-ok     { color: var(--ok);     border-color: var(--ok);     background: var(--ok-soft); }
.badge-warn   { color: var(--warn);   border-color: var(--warn);   background: var(--warn-soft); }
.badge-danger { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

/* Controlled-substance schedules. Monospace so C-II and C-III cannot be
   misread at a glance — the distinction decides whether a Form 222 is needed. */
.sched { font-family: var(--mono); letter-spacing: 0.02em; }

/* --- Definition lists ----------------------------------------------------- */

dl.detail { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1.5rem; margin: 0; }
dl.detail dt { color: var(--text-muted); font-size: 0.85rem; padding-top: 0.1rem; }
dl.detail dd { margin: 0; }
@media (max-width: 560px) {
  dl.detail { grid-template-columns: 1fr; gap: 0.15rem; }
  dl.detail dd { margin-bottom: 0.75rem; }
}

/* --- Misc ----------------------------------------------------------------- */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 0.85rem; }

.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  padding: 1.25rem;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.qr { display: block; margin: 0 auto; image-rendering: pixelated; max-width: 220px; width: 100%; }
.qr svg { width: 100%; height: auto; display: block; }

.secret-box {
  font-family: var(--mono);
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  word-break: break-all;
  padding: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.pagination { display: flex; align-items: center; gap: 0.85rem; margin-top: 1.25rem; flex-wrap: wrap; }
.pagination .spacer { flex: 1; }

.filters {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  align-items: end;
}
/* Named span-2 rather than "wide", which is already a page-wrapper class. */
/* The grid gap spaces these; a bottom margin on top of it would only offset the
   controls from one another, because align-items:end aligns the margin box. */
.filters .field,
.filters .field:last-child { margin-bottom: 0; }

.filters .span-2 { grid-column: 1 / -1; }
@media (min-width: 800px) { .filters .span-2 { grid-column: span 2; } }

.spinner { display: none; color: var(--text-muted); font-size: 0.85rem; }
.htmx-request .spinner { display: inline-block; }

details > summary { cursor: pointer; color: var(--text); }
details > summary:hover { color: var(--accent); }

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 0.75rem;
  top: 0.75rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}

/* ==========================================================================
   Public site — marketing page and legal documents
   ==========================================================================
   These pages face buyers rather than staff, so they run wider and quieter than
   the application: more air, larger serif headings, and no dense chrome. They
   share the same tokens, so the two halves of the product still look related.
   ========================================================================== */

.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.site-nav { display: flex; gap: 1.5rem; flex: 1 1 auto; flex-wrap: wrap; }
.site-nav a { color: var(--text-muted); font-size: 0.95rem; }
.site-nav a:hover { color: var(--accent); text-decoration: none; }
.site-header-actions { display: flex; gap: 0.6rem; align-items: center; }

@media (max-width: 720px) {
  .site-header { padding: 0.85rem 1rem; gap: 0.75rem; }
  .site-nav { order: 3; flex-basis: 100%; gap: 1.1rem; font-size: 0.9rem; }
}

body.public #main { max-width: none; margin: 0; padding: 0; }

.section-inner { max-width: 1080px; margin: 0 auto; padding: 0 2rem; }
.narrow-copy { max-width: 640px; }
@media (max-width: 720px) { .section-inner { padding: 0 1.25rem; } }

.section { padding: 5rem 0; }
.band { background: var(--surface-2); border-block: 1px solid var(--border); }
.section-head { margin-bottom: 3rem; max-width: 46rem; }
.section-head h2 { font-size: 1.9rem; margin-bottom: 0.5rem; }
.section-head p { margin: 0; font-size: 1.05rem; }

/* --- Hero ----------------------------------------------------------------- */

.hero { padding: 6rem 0 5rem; }
.hero-inner { max-width: 1080px; margin: 0 auto; padding: 0 2rem; }
.eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.25rem;
}
.hero-title {
  font-size: clamp(2.2rem, 5.2vw, 3.6rem);
  line-height: 1.08;
  max-width: 20ch;
  margin: 0 0 1.5rem;
}
.hero-lede { max-width: 46rem; color: var(--text-muted); margin: 0 0 2.25rem; font-size: 1.15rem; }
.hero-actions { display: flex; gap: 0.85rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.center-actions { justify-content: center; }
.hero-note { max-width: 34rem; }
.btn-lg { padding: 0.7rem 1.7rem; font-size: 1rem; }

@media (max-width: 720px) { .hero { padding: 3.5rem 0 3rem; } .hero-inner { padding: 0 1.25rem; } }

/* --- Stats ---------------------------------------------------------------- */

.stat-row { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); padding: 3rem 0; }
.stat { display: flex; flex-direction: column; gap: 0.4rem; }
.stat-figure { font-family: var(--serif); font-size: 2rem; color: var(--accent); line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: 0.95rem; }

/* --- Steps ---------------------------------------------------------------- */

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 2.5rem; }
@media (min-width: 860px) { .steps { grid-template-columns: 1fr 1fr; gap: 3rem 3.5rem; } }
.steps li { position: relative; padding-left: 3.75rem; }
.step-num {
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.steps h3 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.steps p { margin: 0; line-height: 1.65; }

/* --- Feature grid --------------------------------------------------------- */

.feature-grid { display: grid; gap: 2.5rem 3rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.feature h3 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.feature h3::before {
  content: "";
  display: block;
  width: 2rem;
  height: 2px;
  background: var(--accent);
  margin-bottom: 0.9rem;
}
.feature p { margin: 0; line-height: 1.65; }

.cta { padding: 5rem 0 6rem; }
.cta h2 { font-size: 1.9rem; }

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

.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 0; }
.site-footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 3.5rem 2rem 2.5rem;
  display: grid;
  gap: 2.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 860px) { .site-footer-inner { grid-template-columns: 1.3fr 2fr; } }
.site-footer-brand p { margin: 0.65rem 0 0; max-width: 22rem; }
.site-footer-links { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.site-footer-links h3 {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}
.site-footer-links a { display: block; color: var(--text-muted); font-size: 0.92rem; margin-bottom: 0.5rem; }
.site-footer-links a:hover { color: var(--accent); text-decoration: none; }
.site-footer-legal {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem 2.5rem;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-footer-legal p { margin: 0; }
@media (max-width: 720px) {
  .site-footer-inner { padding: 2.5rem 1.25rem 2rem; }
  .site-footer-legal { padding: 1.25rem 1.25rem 2rem; }
}

/* --- Legal documents ------------------------------------------------------ */

/* Long-form reading: Lora, a measure that does not run past ~75 characters, and
   headings that separate sections clearly enough to scan for one clause. */
.legal {
  max-width: 46rem;
  margin: 0 auto;
  padding: 3.5rem 2rem 6rem;
  font-family: var(--prose);
  font-size: 1.02rem;
  line-height: 1.75;
}
.legal-head { margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.legal-head h1 { font-size: 2.4rem; margin-bottom: 0.4rem; }
.legal-head p { margin: 0; font-family: var(--sans); font-size: 0.92rem; }
.legal .lead { font-size: 1.15rem; color: var(--text-muted); margin-bottom: 2.5rem; }
.legal h2 {
  font-size: 1.35rem;
  margin: 2.75rem 0 0.85rem;
  padding-top: 0.5rem;
}
.legal h3 { font-size: 1.1rem; margin: 1.75rem 0 0.6rem; }
.legal p { margin: 0 0 1.15rem; }
.legal ul { margin: 0 0 1.35rem; padding-left: 1.3rem; }
.legal li { margin-bottom: 0.6rem; }
.legal strong { font-weight: 700; }
.legal .table-wrap { font-family: var(--sans); font-size: 0.92rem; margin: 1.5rem 0 2rem; }
.legal .table-wrap table { font-size: 0.88rem; }
.legal a { text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 720px) {
  .legal { padding: 2rem 1.25rem 4rem; font-size: 1rem; }
  .legal-head h1 { font-size: 1.9rem; }
}

/* ==========================================================================
   Sign-in and account-setup pages
   ==========================================================================
   These are the first thing a new pharmacist sees, and the only page an attacker
   sees. Quiet, centred, and unmistakably part of the product — with the passkey
   route presented first because it is both easier and harder to phish.
   ========================================================================== */

body.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
}

.auth-header { padding: 1.5rem 2rem; }
.auth-header .brand { font-size: 1.45rem; }

.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.25rem 3rem;
  max-width: none;
  margin: 0;
  width: 100%;
}
.auth-main > .notice { width: 100%; max-width: 27rem; }

.auth-card {
  width: 100%;
  max-width: 27rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2.5rem 2.25rem;
}
.auth-card h1 { font-size: 1.85rem; margin-bottom: 0.35rem; }
.auth-sub { color: var(--text-muted); margin: 0 0 1.75rem; font-size: 0.95rem; }
.auth-passkey-note { margin: 0.75rem 0 0; }
.auth-foot-note { margin-top: 1.5rem; text-align: left; line-height: 1.55; }

/* A labelled rule, rather than a bare "or" floating between two buttons. */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 1.75rem 0;
  color: var(--text-faint);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.auth-aside { margin: 1.5rem 0 0; color: var(--text-muted); text-align: center; }

.auth-footer {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 1.5rem 2rem 2.5rem;
  font-size: 0.85rem;
}
.auth-footer a { color: var(--text-muted); }
.auth-footer a:hover { color: var(--accent); }

@media (max-width: 520px) {
  .auth-header { padding: 1.25rem 1.25rem 0.5rem; }
  .auth-card { padding: 1.75rem 1.35rem; border-radius: 6px; }
  .auth-main { justify-content: flex-start; padding-top: 1.5rem; }
}

/* The setup and challenge pages reuse the same shell. */
.auth-page .card { border-radius: 8px; }

/*
 * Controls that exist only for people without JavaScript.
 *
 * A pharmacy switcher that needs a "Switch" button is fine; one that silently
 * does nothing is not. The select submits itself when scripting is available, and
 * the button is the fallback when it is not.
 */
[data-js] .js-optional { display: none; }

/* --- Email chip field ------------------------------------------------------
 * Reads as one input containing pills, the way an address field does in a mail
 * client. Without scripting the underlying text input is shown instead, so the
 * field still works — it just wants commas.
 */
.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  min-height: 2.6rem;
  padding: 0.35rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: text;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.chips:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  padding: 0.15rem 0.3rem 0.15rem 0.6rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 0.87rem;
  line-height: 1.5;
}
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A malformed address is shown rather than silently dropped, so it can be fixed. */
.chip-invalid { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

.chip-remove {
  border: none;
  background: none;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.15rem;
  cursor: pointer;
  opacity: 0.65;
  border-radius: 50%;
}
.chip-remove:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); }
.chip-remove:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; opacity: 1; }

.chips-entry {
  flex: 1 1 8rem;
  min-width: 8rem;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0.2rem 0.15rem !important;
  min-height: 0 !important;
  font-size: 0.95rem;
}

/* The chip control replaces its own input, so hide the original once it is live. */
input[data-chips][type="hidden"] + .chips { margin-top: 0; }

/* --- Back link ------------------------------------------------------------
 * Sub-pages get one, top left, above the heading. Browser back is not a
 * substitute: after a form post it re-submits or warns, and people stop using it.
 */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.back-link:hover { color: var(--accent); text-decoration: none; }
.back-arrow { font-size: 1.05rem; line-height: 1; }

/* Quick actions inside a table row.
   The cell stays a table-cell. Setting display:flex on a <td> takes it out of
   table layout entirely, which silently drops the vertical-align:middle above and
   floats the buttons a few pixels above the row's text. Inline-block forms keep
   the cell aligned with every other cell and still wrap on a narrow screen. */
td.row-actions { text-align: right; }
td.row-actions form {
  display: inline-block;
  margin: 0.1rem 0 0.1rem 0.3rem;
  vertical-align: middle;
}

/* A destructive action that is a normal part of the workflow rather than a
   warning. Denying a request is routine — it should not shout like deleting a
   pharmacy does. */
/* An action that is available but should never compete for attention — undo. */
.btn-quiet {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--surface);
}
.btn-quiet:hover { color: var(--text); border-color: var(--border-strong); }

.btn-quiet-danger {
  color: var(--danger);
  border-color: var(--danger-soft);
  background: var(--surface);
}
.btn-quiet-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* A block of text meant to be copied whole rather than read — an SSH key, a
   command. Distinct from .secret-box, which presents a short TOTP secret for
   someone to type; this one is long, wraps nothing, and scrolls internally so a
   private key never stretches the page. */
.key-box {
  display: block;
  width: 100%;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: 0.75rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  resize: vertical;
  white-space: pre;
  overflow-x: auto;
}
.key-box:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Long unbroken strings — a public key — wrap rather than widen the card. */
code.wrap {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* --- Reorder match lists --------------------------------------------------
   One line per pharmacy that can cover a want. Deliberately plain: the only
   thing that should catch the eye in this cell is the amber strength badge on
   a different-strength match, because that is the one a reader must not skim
   past. */
.reorder-matches {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.reorder-matches li {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
}
.reorder-store { font-weight: 600; }
.reorder-qty { font-family: var(--mono); color: var(--text-muted); }

/* --- Bulk selection on the reorder page -----------------------------------
   The checkbox sits against the pharmacy that would send the stock, because a
   want is often held by more than one store and picking a source is a real
   choice, not a formatting detail. */
.reorder-matches li + li { padding-top: 0.3rem; border-top: 1px solid var(--border); }
.reorder-pick { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.reorder-pick input { margin: 0; }
.reorder-amount { margin-left: auto; max-width: 6.5em; }
/* A quantity beside an unticked row is not going anywhere; JS disables it, and
   this makes that visible rather than leaving it looking editable. */
.reorder-amount:disabled { opacity: 0.45; }
.field-error { display: block; margin-top: 0.25rem; font-size: 0.8rem; color: var(--danger); }

/* The action bar. Sticky so a 130-row reorder list does not require scrolling
   back to the bottom to send what you ticked at the top. */
.bulk-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding: 0.9rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -2px 12px rgb(0 0 0 / 0.06);
}
.bulk-bar.is-active { border-color: var(--brand, var(--info)); }
.bulk-count { margin: 0; font-size: 0.9rem; color: var(--text-muted); }
.bulk-bar.is-active .bulk-count { color: var(--text); font-weight: 600; }
.bulk-bar .btn { margin-left: auto; }

/* The Form 222 row on the bulk review page, tied to the line above it. */
.bulk-c2 > td { background: var(--danger-soft); }
.bulk-c2 label { display: block; margin-bottom: 0.35rem; font-size: 0.88rem; }
