/* thePHO palette (brand/README.md). Light only, declared as such, so browsers in
   dark mode don't restyle form controls into white-on-white. */
:root {
  color-scheme: light;
  --plum: #c23d41;
  --plum-dark: #9e2f33;
  --hibiscus: #ed696e;
  --marigold: #f6aa01;
  --dusk: #fad1d4;
  --nimbus: #e3e1e0;
  --onyx: #3c3c3b;
  --muted: #6b6a69;
  --bg: #f7f6f5;
  --card: #ffffff;
  --bad: #a4262c;
  --bad-bg: #fdecec;
  --warn-bg: #fff4d6;
  --ok: #1e6b3a;
  --ok-bg: #e5f4ea;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--onyx);
  font-family: "Source Sans 3", "Source Sans Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
}
a { color: var(--plum); }
a:hover { color: var(--plum-dark); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 14px 0 6px; }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.eyebrow { margin: 0; color: var(--muted); font-size: .9rem; }
.mt { margin-top: 18px; }

.top { background: var(--card); border-bottom: 1px solid var(--nimbus); margin-bottom: 24px; }
.top-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand img { display: block; height: 36px; width: auto; }
.top-title { color: var(--muted); }
.top-out { margin-left: auto; }
.foot { color: var(--muted); font-size: .9rem; padding-top: 24px; padding-bottom: 32px; }
.foot p { margin: 0 0 4px; }
.madeby { font-size: .8rem; color: #8a8988; }

.card { background: var(--card); border: 1px solid var(--nimbus); border-radius: 8px; padding: 20px 24px; margin-bottom: 20px; }
.narrow { max-width: 560px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  font: inherit; color: inherit; background: #fff;
  border: 1px solid #b9b7b5; border-radius: 4px; padding: 6px 8px; max-width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid var(--dusk); outline-offset: 1px; border-color: var(--plum); }
input[type=email], input[type=text], input[type=tel] { width: 100%; }
/* Radios and checkboxes must never be stretched by a width:100% meant for text
   inputs — that detaches the control from its label. */
input[type=radio], input[type=checkbox] { width: auto; max-width: none; margin: 0; flex: 0 0 auto; }
input.code { font-size: 1.5rem; letter-spacing: .3em; width: 9em; }
textarea { width: 100%; }
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0 16px; }

button, .button {
  font: inherit; cursor: pointer; border-radius: 4px; padding: 8px 16px;
  border: 1px solid transparent; text-decoration: none; display: inline-block;
}
button.primary { background: var(--plum); color: #fff; }
button.primary:hover { background: var(--plum-dark); }
button.secondary, .button.secondary { background: #fff; color: var(--plum); border-color: var(--plum); }
button.secondary:hover, .button.secondary:hover { background: var(--dusk); }
button.link { background: none; border: none; color: var(--plum); padding: 2px 4px; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

.alert { padding: 10px 14px; border-radius: 4px; margin: 0 0 16px; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: #5c3f00; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; background: var(--nimbus); white-space: nowrap; }
.pill.complete { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.pill.not-started { background: var(--warn-bg); }
.pill.test { background: #e8e3f5; color: #4b3b7a; font-weight: 600; }
tr.testrow td { background: #f8f6fc; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 1px solid var(--nimbus); border-radius: 999px; padding: 3px 12px; font-size: .9rem; }
.chip.warn { background: var(--warn-bg); border-color: var(--marigold); }
.chip.ok { background: var(--ok-bg); border-color: #b8dcc4; }
.chip.flag { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

.key { border-left: 4px solid var(--plum); }
.key .due { margin: 0 0 8px; color: var(--plum-dark); }
.key p { margin: 8px 0 0; }

/* ---- the questionnaire ---- */
.q h2 { display: flex; align-items: baseline; gap: 10px; font-size: 1.15rem; }
.qn {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.9em; height: 1.9em; padding: 0 .4em; border-radius: 999px;
  background: var(--plum); color: #fff; font-size: .85rem; font-weight: 700;
}
.qhelp { color: var(--muted); margin: 0 0 12px; }
.setall { margin: 0 0 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.daygroup { margin-bottom: 14px; }
.daygroup-h { margin: 10px 0 6px; color: var(--plum-dark); font-size: .95rem; }
table.matrix { border-collapse: collapse; width: 100%; }
table.matrix th, table.matrix td { text-align: center; padding: 6px 8px; border-bottom: 1px solid var(--nimbus); }
table.matrix th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #fbfaf9; }
table.matrix th:first-child, table.matrix td.daylabel { text-align: left; }
td.daylabel { font-weight: 600; white-space: nowrap; }
.opt { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; cursor: pointer;
       padding: 4px 8px; border-radius: 4px; }
.opt:has(input:checked) { background: var(--dusk); font-weight: 600; }
.opt.opt-closed:has(input:checked) { background: #f3dada; }
/* In the desktop matrix the column header names the option, so the per-cell text
   is kept for screen readers only. It reappears when the matrix stacks on mobile. */
.matrix .opt span {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.redrows { display: flex; flex-direction: column; gap: 8px; }
.redrow { display: none; align-items: center; gap: 14px; flex-wrap: wrap;
          padding: 8px 10px; background: #fcfaf7; border: 1px solid var(--nimbus); border-radius: 6px; }
.redrow.on { display: flex; }
.rd-date { font-weight: 600; min-width: 6.5em; }
.rd-time { margin: 0; font-weight: 400; display: inline-flex; align-items: center; gap: 6px; }
.rd-time input { width: 8em; }

/* Each option is its own bordered, selectable box so a question's options read as
   one cluster; only the question label is bold, the option text is normal weight. */
.choices { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.choice { display: flex; align-items: center; gap: 10px; font-weight: 400; margin: 0;
          padding: 9px 12px; border: 1px solid var(--nimbus); border-radius: 6px;
          background: #fff; cursor: pointer; }
.choice span { font-weight: 400; }
.choice:hover { border-color: #c9c7c5; background: #fdfbfa; }
.choice:has(input:checked) { border-color: var(--plum); background: var(--dusk); }
.choice input { flex: 0 0 auto; }

.subq { margin-top: 18px; padding: 14px 16px; border-left: 3px solid var(--dusk); background: #fbf7f6; border-radius: 0 6px 6px 0; }
.subq h3 { margin-top: 0; }

/* Multi-site: one Q2 panel per site, switched with a ← → nav (the slider). Single-
   site practices render a display:contents wrapper instead, so none applies to them.
   Default (no JS): every site-block is visible, stacked. .slider-on (added by JS)
   shows one at a time and reveals the switcher buttons. */
.sitebar { border-left: 4px solid var(--plum); }
.sitebar-intro { margin: 0 0 10px; }
.sitetabs { display: flex; flex-wrap: wrap; gap: 8px; }
.sitetab { display: inline-flex; align-items: center; gap: 6px; font-weight: 600;
  background: #fff; border: 1px solid var(--nimbus); border-radius: 999px;
  padding: 5px 14px; color: var(--plum-dark); text-decoration: none; }
.sitetab:hover { border-color: var(--plum); background: var(--dusk); }
.sitetab.active { background: var(--plum); border-color: var(--plum); color: #fff; }
.sitetab .errdot { display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.3em; height: 1.3em; padding: 0 .3em; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: .78rem; font-weight: 700; }
.sitetab.active .errdot { background: #fff; color: var(--bad); }
.sitemove { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.sitepos { font-weight: 600; }
.sitestep { margin: 18px 0 0; text-align: right; }
.site-block { border-left: 4px solid var(--plum); }
.site-block > h2 { margin-top: 0; }
.siteh .sitecount { display: block; font-size: .8rem; font-weight: 600; color: var(--plum-dark); text-transform: uppercase; letter-spacing: .04em; }
.js-only { display: none; }
.siteslider.slider-on .js-only { display: flex; }
.siteslider.slider-on .sitestep { display: block; }
.siteslider.slider-on .site-block { display: none; }
.siteslider.slider-on .site-block.active { display: block; }
.snav[disabled] { opacity: .45; cursor: default; }
@media (max-width: 600px) { .sitemove { flex-wrap: wrap; } .sitepos { order: -1; width: 100%; } }
.q3h { margin: 18px 0 2px; }

.fields2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; align-items: start; }
.field { margin: 2px 0; }
.field label, .flabel { display: block; font-weight: 600; margin: 8px 0 4px; }
/* A radio group never sits beside another one — it takes a full row, with its
   short options laid out across, directly under the question. */
.fields2 .radiofield { grid-column: 1 / -1; margin-top: 4px; }
.radiofield .choices { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.radiofield .choice { flex: 0 1 auto; }
.field input:not([type=radio]):not([type=checkbox]) { width: 100%; }
.readonly-field { margin: 6px 0; }
.readonly-field .flabel { margin-top: 8px; }
.js-q3a-fields.disabled { opacity: .5; }

.msg { display: block; font-size: .82rem; margin-top: 3px; }
.msg.error { color: var(--bad); }
input.bad, select.bad, textarea.bad { border-color: var(--bad); background: var(--bad-bg); }
tr.bad td.daylabel { color: var(--bad); }

.issues { border-left: 4px solid var(--bad); }
.issues h2 { color: var(--bad); }
.issues .todo { margin: 0 0 8px; padding-left: 20px; }
.todo li { margin-bottom: 4px; }
.todo a { margin-left: 6px; font-size: .9rem; }

.flags-preview { border-left: 4px solid var(--marigold); }
.flags-preview ul { list-style: none; margin: 8px 0; padding: 0; }
.fl { padding: 4px 0 4px 22px; position: relative; }
.fl::before { content: "●"; position: absolute; left: 0; }
.fl.high::before { color: var(--bad); }
.fl.medium::before { color: var(--marigold); }

.flagdot { display: inline-block; font-size: .82rem; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.flagdot.high { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.flagdot.medium { background: var(--warn-bg); color: #7a5300; }

.status { flex: 1 1 100%; margin: 0; font-size: .95rem; }
.status.todo { color: var(--onyx); }
.status.stale { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--nimbus); z-index: 3; margin-top: 0; }

/* ---- admin ---- */
.admin-box .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.linkbox { width: 100%; font-family: ui-monospace, monospace; font-size: .85rem; }
.contact { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--nimbus); padding: 4px 0; }
.contact-add { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.contact-add input[type=email] { width: auto; flex: 1 1 14em; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { margin-bottom: 4px; }

.tablewrap { overflow: auto; }
table.list { border-collapse: collapse; width: 100%; background: var(--card); border: 1px solid var(--nimbus); border-radius: 8px; }
table.list th, table.list td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--nimbus); }
table.list th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #fbfaf9; white-space: nowrap; }
table.list th.r, table.list td.r { text-align: right; }

/* Phones: matrix and list tables become one card per row, each field labelled. */
@media (max-width: 760px) {
  .wrap { padding: 0 12px; }
  .top { margin-bottom: 16px; }
  .top-title { display: none; }
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .head { flex-wrap: wrap; }
  .fields2, .admin-box .grid2 { grid-template-columns: 1fr; }

  table.matrix thead { display: none; }
  table.matrix, table.matrix tbody, table.matrix tr, table.matrix td { display: block; width: 100%; }
  table.matrix tr { background: #fff; border: 1px solid var(--nimbus); border-radius: 8px; margin-bottom: 10px; padding: 8px 10px; }
  table.matrix td { border: 0; text-align: left; padding: 2px 0; }
  table.matrix td.daylabel { font-size: 1rem; margin-bottom: 4px; }
  .matrix .opt { display: flex; }
  .matrix .opt span { position: static; width: auto; height: auto; clip: auto; }

  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { background: var(--card); border: 1px solid var(--nimbus); border-radius: 8px; margin-bottom: 12px; padding: 8px 12px; }
  table.list td { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 2px 10px; padding: 5px 0; border: 0; }
  table.list td::before { content: attr(data-label); font-size: .8rem; font-weight: 600; color: var(--muted); }

  .sticky-actions button { flex: 1 1 100%; }
  .contact-add input[type=email] { flex: 1 1 100%; }
}
