/*
 * The one set of components, at two densities: reading pages at --fs, working tables and their
 * bars at --fs-dense. Names are plain; a page composes them and screens.css adds what one screen needs.
 */

/* A reading page: the title, one line of meta and the actions, then cards on the page */
.page { padding: 22px 28px 32px; }
.page__inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 1040px; margin: 0 auto; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.pagehead h1 { margin: 0; font-size: var(--fs-title); font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.pagehead .meta { margin-top: 2px; max-width: 80ch; color: var(--ink-2); font-size: var(--fs-dense); }
.pagehead .actions { margin-left: auto; }
.pagehead .meta--row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
/* The page above this one, when the rail cannot say it: a facility's organization, say. */
.crumb { display: inline-block; margin-bottom: 2px; color: var(--ink-2); font-size: var(--fs-dense); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tile .v { font-size: 24px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile .l, .tile .of { color: var(--ink-2); font-size: var(--fs-dense); }

/* A card sets off one thing that needs an edge: a table, a form, a facility. */
.card { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.card__head .meta { color: var(--ink-2); font-size: var(--fs-dense); font-weight: 400; }
.card__body { padding: 14px 16px; }
.card__title { margin: 0 0 10px; font-size: var(--fs); font-weight: 600; }
.card__head .card__title { margin: 0; }
.card__note { margin: 0; padding: 12px 16px; color: var(--ink-2); font-size: var(--fs-dense); }
.card__head + .card__note { padding-bottom: 0; }
.card__body > :last-child { margin-bottom: 0; }
.card table th:first-child, .card table td:first-child { padding-left: 16px; }
.card table th:last-child, .card table td:last-child { padding-right: 16px; }

/* What went wrong or needs a person, above the work. Warning unless it says otherwise. */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-size: var(--fs-dense);
}
.banner--bad { border-color: color-mix(in srgb, var(--bad) 25%, transparent); background: var(--bad-soft); color: var(--bad-ink); }
.banner--info { border-color: color-mix(in srgb, var(--info) 25%, transparent); background: var(--info-soft); color: var(--info-ink); }
.banner p { margin: 0; }
.banner p + p { margin-top: 6px; }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }

/* Long text to read: the privacy policy */
.prose { display: grid; gap: 12px; max-width: 72ch; }
.prose p, .prose ul, .prose address { margin: 0; line-height: 1.6; }
.prose h2 { margin: 10px 0 0; font-size: calc(var(--fs) + 2px); font-weight: 600; }
.prose ul { padding-left: 20px; }
.prose address { font-style: normal; }
.prose td { height: auto; padding: 8px 10px; white-space: normal; vertical-align: top; }

/* Sign-in and refusals: one box in the middle of the page */
.authpage { display: grid; place-items: center; padding: 28px 16px; }
.authbox { display: grid; gap: 12px; width: min(380px, 100%); padding: 24px; }
.authbox h1 { margin: 0; font-size: var(--fs-title); font-weight: 600; letter-spacing: -.01em; }
.authbox p { margin: 0; }

/* PointClickCare's sign-in button. The artwork is theirs and is never recoloured or stretched (their
   guidelines), so the button adds nothing visible of its own; three of their SVGs are its three states. */
.pcc-sign-in { display: inline-block; justify-self: start; padding: 0; border: 0; border-radius: 23px; background: none; line-height: 0; cursor: pointer; }
.pcc-sign-in:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pcc-sign-in__state { display: block; width: 229px; max-width: 100%; height: auto; }
.pcc-sign-in__state--hover, .pcc-sign-in__state--pressed { display: none; }
.pcc-sign-in:hover .pcc-sign-in__state--base { display: none; }
.pcc-sign-in:hover .pcc-sign-in__state--hover { display: block; }
.pcc-sign-in:active .pcc-sign-in__state--base, .pcc-sign-in:active .pcc-sign-in__state--hover { display: none; }
.pcc-sign-in:active .pcc-sign-in__state--pressed { display: block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control);
  padding: 0 12px;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--surface); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn--danger:hover { background: var(--bad-ink); border-color: var(--bad-ink); color: var(--surface); }
.btn--sm { height: var(--control-sm); padding: 0 10px; font-size: var(--fs-dense); }
.btn[aria-pressed="true"] { background: var(--selected); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn kbd { margin-left: 2px; }
.btn--primary kbd { background: color-mix(in srgb, var(--surface) 18%, transparent); border-color: color-mix(in srgb, var(--surface) 30%, transparent); color: var(--surface); }

/* A form's fields: a label over its control, a hint under it */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 4px; align-content: start; }
.field__label { color: var(--ink-2); font-size: 12px; font-weight: 500; }
.field__hint { margin: 0; color: var(--ink-3); font-size: 12px; }
.field__hint.caution { color: var(--warn-ink); }
.filterbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.filterbar__grow { flex: 1 1 280px; }

/* Inputs. A select in a row looks like text until it is pointed at. */
.input {
  height: var(--control);
  min-width: 220px;
  padding: 0 10px;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.input--wide { width: 100%; min-width: 0; }
textarea.input { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
.input--sm { height: var(--control-sm); min-width: 0; max-width: 100%; padding: 0 8px; font-size: var(--fs-dense); }
.select {
  appearance: none;
  max-width: 280px;
  padding: 3px 22px 3px 6px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background-color: transparent;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  color: var(--ink);
  font-size: var(--fs-dense);
  text-overflow: ellipsis;
}
.select:hover, .select:focus { border-color: var(--line-strong); background-color: var(--surface); }
.select.unset { color: var(--bad-ink); font-style: italic; }
.select option { color: var(--ink); background: var(--surface); font-style: normal; }
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 220px;
  height: var(--control-sm);
  margin-left: auto;
  padding: 0 8px;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-3);
  font-size: var(--fs-dense);
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search kbd { margin-left: auto; }
/* The reviewer's own count, typed in a row or the panel: orange when it differs from ours. */
.countin {
  width: 64px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-variant-numeric: tabular-nums;
  text-align: right;
  -moz-appearance: textfield;
}
.countin::-webkit-outer-spin-button, .countin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.countin::placeholder { color: var(--ink-3); }
.countin:hover, .countin:focus { border-color: var(--line-strong); background: var(--surface); }
.countin.differs { color: var(--warn-ink); font-weight: 600; }
textarea.note {
  width: 100%;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
}

/* Status: a chip says it, a dot shows it */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok-ink); }
.chip.warn { background: var(--warn-soft); color: var(--warn-ink); }
.chip.bad { background: var(--bad-soft); color: var(--bad-ink); }
.chip.info { background: var(--info-soft); color: var(--info-ink); }
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); }
a.chip:hover { text-decoration: none; filter: brightness(.97); }
.dot { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.off { background: transparent; border: 1.5px solid var(--line-strong); }

/* Tables: 36px rows, numbers tabular and on the right */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-dense); }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
th.num { text-align: right; }
td { height: 36px; padding: 0 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; }
td.dx { max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); font-family: var(--mono); font-size: 11px; }
td.empty { padding: 16px 10px; color: var(--ink-2); }
tr.row { cursor: default; }
tr.row:hover td { background: var(--hover); }
tr.row[aria-selected="true"] td { background: var(--selected); }
tr.row.zero td { color: var(--ink-3); }
tr.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* The link that opens a row's panel: the row is the target, the link is how the keys reach it. */
a.open { color: inherit; }
a.open:hover { text-decoration: none; }

/* An aside that needs a person, with its action on the right. */
.callout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-dense);
}
.callout .btn { margin-left: auto; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; margin: 0; font-size: var(--fs-dense); }
.kv dt { margin: 0; color: var(--ink-3); }
.kv dd { margin: 0; }

/* A working screen: its own bar, a strip of what it holds, a toolbar, the list, a legend */
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; font-size: var(--fs-dense); }
.wsbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 48px; padding: 8px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.wsbar h1 { margin: 0; font-size: var(--fs); font-weight: 600; }
.wsbar .actions { margin-left: auto; }
.wsbar form { display: inline; margin: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; }
.crumbs .sep { color: var(--ink-3); }
.monthnav { display: inline-flex; overflow: hidden; border: 1px solid var(--line-control); border-radius: var(--radius-sm); font-weight: 500; }
.monthnav a, .monthnav span { padding: 3px 8px; background: var(--surface); color: var(--ink-2); }
.monthnav a:hover { background: var(--hover); text-decoration: none; }
.monthnav .off { color: var(--line-strong); }
.monthnav .m { border-left: 1px solid var(--line); border-right: 1px solid var(--line); color: var(--ink); }
.strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 20px; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 20px; }
.screen > .callout { margin: 10px 20px 0; }
.list { flex: 1; min-height: 0; overflow: auto; padding: 0 20px 16px; }
.list th { background: var(--bg); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--bg); color: var(--ink-2); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .keys { margin-left: auto; }
.pagenote { margin: 0 20px 16px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); font-size: 12px; }

/* Two views of one list, and the filters within one */
.segv { display: inline-flex; overflow: hidden; border: 1px solid var(--line-control); border-radius: var(--radius-sm); }
.segv a { padding: 4px 10px; background: var(--surface); color: var(--ink-2); }
.segv a + a { border-left: 1px solid var(--line-strong); }
.segv a:hover { background: var(--hover); text-decoration: none; }
.segv a[aria-current] { background: var(--selected); color: var(--accent-ink); font-weight: 500; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill { padding: 3px 10px; border: 1px solid transparent; border-radius: 999px; color: var(--ink-2); }
.pill:hover { background: var(--hover); text-decoration: none; }
.pill[aria-current] { background: var(--surface); border-color: var(--line-control); color: var(--ink); font-weight: 500; }
.segv b, .pill b { margin-left: 4px; color: var(--ink-3); font-weight: 500; }

/* A long job (reading PDFs, deciding orders), polled while it runs */
.progress { display: inline-flex; align-items: center; gap: 8px; }
.progress i { display: inline-block; width: 140px; height: 6px; overflow: hidden; border-radius: 3px; background: var(--sunken); }
.progress i b { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.activity { padding: 8px 20px 20px; }
.activity summary { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12px; list-style: none; cursor: pointer; }
.activity summary::-webkit-details-marker { display: none; }
.activity summary::before { content: "▸"; font-size: 10px; }
.activity[open] summary::before { content: "▾"; }
.activity ul { display: grid; gap: 4px; margin: 8px 0 0; padding: 0; color: var(--ink-2); font-size: 12px; list-style: none; }
.activity li { display: grid; grid-template-columns: 56px 1fr; gap: 10px; }

/* The detail panel's contents */
.panel__head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.panel__title { margin: 0; font-size: var(--fs); font-weight: 600; }
.panel__sub { color: var(--ink-2); font-size: var(--fs-dense); }
.panel__close { margin-left: auto; padding: 2px 6px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-3); font-size: 16px; line-height: 1; }
.panel__close:hover { background: var(--hover); color: var(--ink); }
.panel section { display: grid; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: var(--fs-dense); }
.panel h4 { margin: 0; color: var(--ink-3); font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.panel p { margin: 0; }
.bigcode { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.bigcode .code { font: 600 18px/1 var(--mono); }
.notelist { display: grid; gap: 2px; margin: 0; padding-left: 16px; color: var(--ink-2); }
.order { display: grid; gap: 6px; padding: 10px 0; border-top: 1px dashed var(--line); }
.order:first-of-type { padding-top: 0; border-top: 0; }
.order__text { display: -webkit-box; overflow: hidden; font-family: var(--mono); font-size: 12px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.order__text.full { -webkit-line-clamp: unset; }
.order__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--ink-2); font-size: 12px; }
.order__meta .select { max-width: 100%; }
.order__meta form { display: inline; margin: 0; }
.ai { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: 12px; }
.ai b { color: var(--accent-ink); }

/* A dialog drawn as a sheet */
dialog.sheet-dialog { max-width: calc(100% - 32px); padding: 0; border: 0; background: transparent; }
dialog.sheet-dialog::backdrop { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.sheet { display: grid; gap: 14px; width: min(520px, 100vw - 32px); padding: 18px 20px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: var(--fs-dense); }
.sheet h3 { margin: 0; font-size: 15px; }
.sheet .counts { display: grid; gap: 8px; }
.sheet .counts div { display: flex; align-items: flex-start; gap: 10px; }
.sheet .counts .dot { margin-top: 5px; }
.sheet .actions { justify-content: flex-end; }
.drop { position: relative; padding: 26px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); color: var(--ink-2); text-align: center; }
.drop b { color: var(--ink); }
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:focus-within { border-color: var(--accent); }
.files { display: grid; gap: 4px; margin: 0; padding: 0; font-size: 12px; list-style: none; }
.files li { display: flex; justify-content: space-between; padding: 6px 8px; border-radius: 4px; background: var(--sunken); }
.caution:empty { display: none; }

@media (max-width: 760px) {
  .page { padding: 16px; }
  .wsbar, .strip, .toolbar, .legend, .list, .activity { padding-left: 16px; padding-right: 16px; }
  .screen > .callout, .pagenote { margin-left: 16px; margin-right: 16px; }
  .search { width: 100%; min-width: 0; margin-left: 0; }
}

/* Printing a page prints all of it: no inner scroll. */
@media print {
  .screen, .list { overflow: visible; }
}

/* A row with an edit not yet saved; the re-drawn row arrives without it. */
tr.row.edited, tr.row.edited td { background: var(--warn-soft); }
