/* The redesign sweep's shared patterns (#536): the styles for the macros in
   app/templates/_patterns.html and other shared patterns. Loaded by the page
   shells after record.css. Colours come from the tokens in app.css
   (each already has its dark twin), so nothing here needs a dark-mode rule.
   Phone layouts begin at 760px. */

.pt-k { font-size:.8rem; color:var(--muted); }
.pt-bulk-result-at { margin:-.4rem 0 .9rem; }
.pt-bulk-result-actions { display:flex; gap:.6rem; flex-wrap:wrap; margin-top:1rem; }
.pt-k.pt-note { margin:.3rem 0 0; }
.pt-empty { color:var(--muted); padding:2rem 1rem; text-align:center; margin:0; }

/* ---------- page head ---------- */
.pt-back { margin:0 0 .3rem; font-size:.9rem; font-weight:600; }
.pt-back a { text-decoration:none; }
.pt-head { display:flex; align-items:flex-end; justify-content:space-between; gap:24px; flex-wrap:wrap; margin-bottom:1rem; }
.pt-head-t { min-width:0; flex:1 1 20rem; }
.pt-head-t .sub { margin-bottom:0; }
.pt-head-a { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.pt-head-a .btn, .pt-head-a button { margin:0; }

/* ---------- notice ---------- */
.pt-notice { margin:0 0 16px; padding:10px 14px; border-radius:8px; background:var(--surface);
  border:1px solid var(--rule); border-left:4px solid var(--accent); font-size:.9rem; }
.pt-notice.ok { border-color:var(--ok-line); border-left-color:var(--accent); }
.pt-notice.warn { border-color:var(--warn-line); border-left-color:var(--ochre); }
.pt-notice.bad { border-color:var(--bad-line); border-left-color:var(--sev-high); }
.pt-notice.info { border-left-color:var(--mut-line); }
.pt-notice > p { margin:0; }
.pt-notice > p + p { margin-top:4px; }

/* ---------- confirm box ---------- */
.pt-confirm { margin:0 20px 14px; padding:12px 14px; border-radius:8px; background:var(--warn-bg);
  border:1px solid var(--warn-line); color:var(--ink); font-size:.9rem; }
.pt-confirm p { margin:0; }
.pt-confirm form { display:flex; gap:8px; flex-wrap:wrap; margin:10px 0 0; }
.pt-confirm button, .pt-confirm .btn { margin:0; }

/* ---------- catalogue card ---------- */
.cat-card .card-h { flex-wrap:nowrap; container-type:inline-size; }   /* Edit never wraps under the title, phone included */
.cat-card .cat-id { display:flex; align-items:center; gap:12px; flex:1 1 0; min-width:0; }
.cat-card .card-h .btn-edit { flex:none; }
.cat-card .card-t { min-width:0; }
/* A narrow card (1024 with two columns, a phone): the pill goes under the title, so the
   title keeps the width and never breaks inside a word. */
@container (max-width: 26rem) {
  .cat-card .cat-id { flex-wrap:wrap; row-gap:4px; }
  .cat-card .cat-id:has(> .cat-pos) { display:grid; grid-template-columns:20px minmax(0, 1fr); gap:4px 12px; }
  .cat-card .cat-id:has(> .cat-pos) > .pill { grid-column:2; justify-self:start; }
}
.cat-card .cat-pos { width:20px; font-size:.82rem; font-weight:700; color:var(--muted); font-variant-numeric:tabular-nums; }
.cat-card .card-t, .cat-card .card-b { overflow-wrap:anywhere; }
.cat-card.is-off .card-t { color:var(--muted); }
.cat-card .cat-acts { justify-content:space-between; align-items:center; }
.cat-card .cat-order { display:inline-flex; align-items:center; gap:2px; }
.cat-card .cat-order form, .cat-card .cat-acts form { margin:0; }
.cat-card button.icon { width:32px; height:32px; padding:0; margin:0; border:0; border-radius:6px;
  background:transparent; color:var(--ink-2); display:inline-flex; align-items:center; justify-content:center; }
.cat-card button.icon:hover { background:var(--ground); }
.cat-card button.icon:disabled { color:var(--mut-line); cursor:not-allowed; background:transparent; }
.cat-card .cat-order .pt-k { margin-left:6px; }
.cat-card button.pt-deact, .cat-card button.sec.sm { margin:0; }
/* Switching a row off is not a deletion: it is undone by the toast and by Bring back,
   and an in-use row asks first in its own confirm box. So it is styled like a danger
   button but is not one for the confirmation ratchet. */
button.pt-deact { background:none; color:var(--risk); border-color:var(--risk); }
button.pt-deact.sm { margin:0; }   /* height and type come from button.sm: the 32px small size (#1621 D1) */
.cat-card .cat-confirm { padding-top:0; }
.cat-card .card-form .card-b > * + * { margin-top:12px; }
.cat-card .card-form label { margin-top:0; }
.cat-list { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:14px; align-items:start; }
.cat-list > .card { margin:0; }
.cat-facts { display:grid; grid-template-columns:repeat(auto-fill, minmax(min(100%, 8.5rem), 1fr)); gap:6px 18px; font-size:.86rem; margin-top:8px; }
.cat-facts > :only-child { grid-column:1 / -1; }   /* a one-fact line (a code, a sentence) keeps the full width */

/* ---------- history ---------- */
.pt-seg { display:inline-flex; flex-wrap:wrap; align-items:center; row-gap:6px; }
.pt-seg a { display:inline-flex; align-items:center; height:30px; padding:0 12px; border:1px solid var(--rule); white-space:nowrap;
  background:var(--surface); color:var(--ink-2); font-size:.8rem; font-weight:600; text-decoration:none; }
.pt-seg a:first-child { border-radius:6px 0 0 6px; }
.pt-seg a:last-child { border-radius:0 6px 6px 0; border-left:0; }
.pt-seg a.on { background:var(--ink); color:var(--surface); border-color:var(--ink); }
.pt-hist { list-style:none; margin:0; padding:0; }
.pt-hist li { position:relative; padding:12px 20px 12px 44px; border-top:1px solid var(--rule-soft); font-size:.9rem; }
.pt-hist li:first-child { border-top:0; }
.pt-dot { position:absolute; left:20px; top:17px; width:12px; height:12px; border-radius:50%;
  background:var(--surface); border:2px solid var(--accent); }

/* ---------- settings-table row ---------- */
.pt-head-row, .pt-cells { display:grid; grid-template-columns:var(--pt-cols, repeat(4, minmax(0, 1fr)) 70px); gap:14px;
  align-items:center; padding:11px 20px; }
.pt-row { border-top:1px solid var(--rule-soft); }
.pt-row:first-of-type { border-top:0; }
.pt-cells[hidden], .pt-row form[hidden] { display:none; }
.pt-cell { min-width:0; overflow-wrap:anywhere; }
.pt-cell-a { justify-self:end; }
.pt-head-row { font-size:.7rem; letter-spacing:.08em; text-transform:uppercase; color:var(--ink-2); font-weight:600;
  background:var(--head-bg); border-bottom:1px solid var(--rule); padding-top:9px; padding-bottom:9px; }
.pt-rowform { padding:12px 20px 14px; background:var(--hover-bg); }
.pt-rowform .err-note { color:var(--bad-ink); font-size:.85rem; margin:0 0 .6rem; }
.pt-fields { display:grid; grid-template-columns:repeat(auto-fit, minmax(10rem, 1fr)); gap:12px; align-items:start; }
.pt-fields label { margin:0; }
/* A titled group of fields in a card form (#1709 Applies to): it takes the whole row. A group of
   checkboxes inside is the shared fieldset.choice, its legend set like the field captions beside it. */
.pt-fields .pt-group, .pt-fields .pt-wide { grid-column:1 / -1; }
fieldset.pt-group { border:0; padding:0; margin:0; min-width:0; }
fieldset.pt-group > legend { padding:0; margin:0 0 .2rem; font-size:.92rem; font-weight:600; color:var(--ink); }
.pt-fields fieldset.choice { margin:0; min-width:0; }
.pt-fields fieldset.choice > legend { padding:0; margin:0 0 .3rem; font-size:.68rem; letter-spacing:.09em;
  text-transform:uppercase; color:var(--muted); }
.pt-rowform-f { display:flex; gap:8px; justify-content:flex-end; margin-top:12px; }
.pt-rowform-f .btn, .pt-rowform-f button { margin:0; }

/* ---------- tiles ---------- */
.pt-tiles { display:flex; gap:12px; flex-wrap:wrap; margin:0 0 16px; }
.pt-tile { display:flex; flex-direction:column; gap:2px; min-width:7.5rem; padding:12px 16px; border:1px solid var(--rule);
  border-radius:8px; background:var(--surface); color:var(--ink); text-decoration:none; }
a.pt-tile:hover { border-color:var(--accent); }
.pt-tile.on { border-color:var(--accent); box-shadow:0 0 0 2px var(--ok-bg); }
.pt-n { font-size:1.5rem; font-weight:600; font-variant-numeric:tabular-nums; line-height:1.1; }
.pt-l { font-size:.8rem; color:var(--muted); }
.pt-tile.bad .pt-n { color:var(--bad-ink); }
.pt-tile.warn .pt-n { color:var(--warn-ink); }
.pt-tile.ok .pt-n { color:var(--ok-ink); }

/* ---------- result rows ---------- */
.pt-results { background:var(--surface); border:1px solid var(--rule); border-radius:10px; }
.pt-results th { padding:.7rem 16px; background:var(--head-bg); color:var(--ink-2); border-bottom:1px solid var(--rule); }
.pt-results td { padding:8px 16px; border-bottom:0; border-top:1px solid var(--rule-soft); }
.pt-results .nw { white-space:nowrap; }
@media (min-width: 761px) and (max-width: 1100px) {
  .pt-results [data-priority="low"] { display:none; }   /* same rule as .rtable (app.css) */
}
.pt-line + .pt-line { margin-top:4px; }
.pt-retry { margin:6px 0 0; }
.pt-retry button { margin:0; }

/* ---------- views menu ---------- */
.pt-menu-h { font-size:.7rem; letter-spacing:.08em; text-transform:uppercase; color:var(--ink-2); font-weight:600;
  padding:8px 12px 4px; }
.pt-menu-h ~ .pt-menu-h { margin-top:6px; border-top:1px solid var(--rule-soft); padding-top:10px; }

/* ---------- form layout ---------- */
.form-cols { display:grid; grid-template-columns:minmax(0, 1.7fr) minmax(0, 1fr); gap:16px; align-items:start; }
.form-sec { margin:0 0 16px; }
.form-sec .card-b > label:first-child { margin-top:0; }
.form-aside { padding:14px 16px; border:1px solid var(--rule); border-radius:10px; background:var(--surface);
  font-size:.88rem; color:var(--ink-2); }
.form-aside h3 { margin:0 0 6px; font-size:.92rem; color:var(--ink); }
.form-aside > :last-child { margin-bottom:0; }
.pt-submit { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
  margin-top:8px; padding:12px 0; }
.pt-submit-b { display:flex; gap:8px; align-items:center; }
.pt-submit .btn, .pt-submit button { margin:0; }
.pt-tpl-id { display:inline-block; max-width:100%; vertical-align:bottom; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:.82rem; }

/* ---------- error pages: 403, not switched on, 404, blocked banner ---------- */
.pt-error-head { display:flex; align-items:center; justify-content:space-between; min-height:56px;
  gap:12px; padding:0 16px; background:var(--rail); color:var(--rail-ink); font-size:.82rem; }
.pt-error-head a { color:var(--rail-ink); font:600 1.2rem var(--serif); text-decoration:none; }
.pt-error-main { max-width:1080px; margin:0 auto; }
.pt-err-tag { display:flex; align-items:center; gap:8px; margin:6px 0 14px; }
.pt-err-actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-top:18px; }
.pt-err-actions .btn, .pt-err-actions button { margin:0; }
.pt-find { position:relative; max-width:460px; margin-top:16px; }
.pt-blocked { padding:0; overflow:hidden; }
.pt-blocked-h { padding:12px 16px; }
.pt-blocked-d > summary { cursor:pointer; padding:0 16px 12px; font-size:.86rem; font-weight:600; color:var(--accent); }
.pt-blocked-i { display:flex; gap:12px; align-items:flex-start; justify-content:space-between; padding:12px 16px;
  border-top:1px solid var(--rule-soft); }
.pt-blocked-i a { font-weight:600; white-space:nowrap; font-size:.86rem; }

/* ---------- toast with a button ---------- */
.pt-toast form { margin:0; }
.pt-toast button.sm { padding:.15rem .6rem; }

@media (max-width: 760px) {
  :where(body:not(.outside)) .card-h { flex-wrap:wrap; }
  .cat-list { grid-template-columns:minmax(0, 1fr); }
  .form-cols { grid-template-columns:1fr; }
  .pt-head { align-items:stretch; }
  .pt-head-row { display:none; }
  .pt-cells { grid-template-columns:1fr 1fr; gap:6px 12px; }
  .pt-cell[data-label]::before { content:attr(data-label); display:block; font-size:.72rem; color:var(--muted);
    letter-spacing:.06em; text-transform:uppercase; }
  .pt-cell-a { grid-column:1 / -1; justify-self:start; }
  .pt-results thead { display:none; }
  /* sortable headers stay as one wrapping strip above the cards (#1598; see app.css .th-sort) */
  .pt-results thead:has(th[data-sortable]) { display:block; }
  .pt-results thead:has(th[data-sortable]) tr { display:flex; flex-wrap:wrap; gap:0 8px; padding:0 8px; border-top:0; }
  .pt-results thead:has(th[data-sortable]) th { display:none; }
  .pt-results thead:has(th[data-sortable]) th[data-sortable] { display:block; width:auto !important; padding:0 8px; border:0;
    background:none; }
  .pt-results, .pt-results tbody, .pt-results tr, .pt-results td { display:block; width:auto; }
  .pt-results tr { padding:8px 0; border-top:1px solid var(--rule-soft); }
  .pt-results tr:first-child { border-top:0; }
  .pt-results td { border:0; padding:4px 16px; }
  .pt-results td[data-label]::before { content:attr(data-label); display:block; font-size:.72rem; color:var(--muted);
    letter-spacing:.06em; text-transform:uppercase; }
  .pt-tile { flex:1 1 7rem; }
  .pt-hist li { padding-left:40px; }
  .pt-submit { position:sticky; bottom:0; z-index:20; margin:16px -16px 0; padding:12px 16px;
    background:var(--surface); border-top:1px solid var(--rule); box-shadow:0 -6px 16px rgba(14,28,27,.08); }
  .pt-submit-b { width:100%; }
  .pt-submit-b .btn, .pt-submit-b button { flex:1 1 0; text-align:center; min-height:44px; }
  .pt-submit-b .ah { flex:1 1 0; min-width:0; display:flex; }
  .pt-submit-b .ah > .btn, .pt-submit-b .ah > button:not(.ah-i) { flex:1 1 0; min-width:0; }
  .pt-submit-b .ah-i { flex:0 0 44px; width:44px; height:44px; order:1; }
  .pt-submit-b .ah-hint { order:2; }   /* the (i) sits beside the button; the hint wraps below both */
}

/* ===== Overview band (pt.overview_band) and the Views-menu count pill ===== */
.pt-band { background:var(--surface); border:1px solid var(--rule); border-radius:10px; margin:1.1rem 0 0; }
.pt-band-h { display:flex; align-items:center; gap:14px; padding:.55rem .6rem .55rem 1rem; min-width:0; }
.pt-band-title { margin:0; font-family:var(--sans); font-size:.78rem; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--ink-2); flex:none; cursor:help; }
.pt-band-hint { margin:0; padding:0 1rem .5rem; color:var(--muted); font-size:.8rem; overflow-wrap:anywhere; }
.pt-band-sum { margin:0; flex:1 1 auto; min-width:0; font-size:.88rem; color:var(--ink-2); display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; overflow:hidden; }
.pt-band-sum a { color:inherit; text-decoration:none; font-variant-numeric:tabular-nums; }
.pt-band-sum a:hover { color:var(--accent); text-decoration:underline; }
.pt-band-sum a.on { color:var(--accent); font-weight:600; }
.pt-band-sum span { color:var(--muted); }
.pt-band-tg { margin:0; flex:none; }
/* app.css gives every button display:inline-block, which beats the UA's [hidden] rule: without
   this the toggle would show, dead, before band.js runs or when it never does. */
.pt-band-tg[hidden] { display:none; }
.pt-band[data-open="true"] .pt-band-sum { visibility:hidden; }
.pt-band-b { padding:0 1rem 1rem; }
.pt-band-b[hidden] { display:none; }
.pt-band-grid { display:grid; grid-template-columns:repeat(6, minmax(0,1fr)); gap:10px; }
.pt-band-t { grid-column:span 2; display:flex; flex-direction:column; gap:2px; min-width:0; padding:10px 14px; border:1px solid var(--rule); border-radius:8px; background:var(--surface); color:var(--ink); text-decoration:none; }
.pt-band-t:hover { border-color:var(--accent); }
.pt-band-t.on { border-color:var(--accent); box-shadow:0 0 0 2px var(--ok-bg); }
.pt-band-n { font-size:1.45rem; font-weight:600; font-variant-numeric:tabular-nums; line-height:1.1; }
.pt-band-l { font-size:.8rem; color:var(--muted); }
.pt-band-s { font-size:.74rem; color:var(--ink-2); margin-top:2px; }
.pt-band-t.warn .pt-band-n { color:var(--warn-ink); }
.pt-band-g { grid-column:span 4; display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:1px; background:var(--rule); border:1px solid var(--rule); border-radius:8px; overflow:hidden; }
.pt-band-g .pt-band-t { grid-column:auto; border:0; border-radius:0; box-shadow:none; }
.pt-band-g .pt-band-t:hover { background:var(--hover-bg); }
.pt-band-g .pt-band-t.on { box-shadow:inset 0 0 0 2px var(--accent); }
.pt-band-gh { grid-column:1 / -1; background:var(--head-bg); padding:5px 14px; font-size:.7rem; letter-spacing:.08em; text-transform:uppercase; font-weight:600; color:var(--ink-2); }
.pt-vc { display:inline-block; min-width:1.4rem; margin-left:4px; padding:0 .35rem; border-radius:99px; border:1px solid var(--rule); font-size:.74rem; font-weight:600; text-align:center; font-variant-numeric:tabular-nums; color:var(--ink-2); }
@media (max-width:760px) {
  .pt-band-h { flex-wrap:wrap; gap:6px 10px; padding:.6rem .75rem; }
  .pt-band-title { order:1; }
  /* two classes: app.css's `button.sm { margin:0 }` outranks one */
  .pt-band .pt-band-tg { order:2; margin-left:auto; }
  .pt-band-sum { order:3; flex-basis:100%; display:block; white-space:normal; overflow:visible; line-height:1.55; }   /* the phone shows every number: no clamp */
  .pt-band[data-open="true"] .pt-band-sum { display:none; }
  .pt-band-b { padding:0 .75rem .75rem; }
  .pt-band-grid { grid-template-columns:repeat(2, minmax(0,1fr)); grid-auto-flow:dense; }
  .pt-band-t { grid-column:span 1; }
  .pt-band-g { grid-column:span 2; }
  .pt-band-g .pt-band-t { padding:9px 10px; }
}

/* ---------- sort a card list (#1614) ---------- */
.pt-sort { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:0 0 12px;
  padding:9px 11px; border:1px solid var(--rule); border-radius:8px; background:var(--surface); }
.pt-sort label { display:inline; margin:0; text-transform:none; letter-spacing:0;
  color:var(--muted); font-size:.85rem; font-weight:600; }
.pt-sort select { width:auto; flex:0 1 auto; min-width:150px; margin:0; }
.pt-sort .btn { margin:0; }
/* Phone (#2415): the two selects and Apply share one row; the visible label is spoken, not drawn. */
@media (max-width:760px) {
  .pt-sort { gap:6px; }
  .pt-sort > label:first-of-type { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
  .pt-sort select { flex:1 1 0; min-width:0; width:auto; min-height:44px; }
  .pt-sort .btn { flex:0 0 auto; min-height:44px; }
}

/* Practice notes (#2154): the workspace and the onboarding question list. */
/* Cards on this page keep the standard 16px gap. */
#pn-workspace > .card, #pn-workspace > form.card, #pn-workspace > details.card, #pn-workspace > form:not(.card) { margin:0 0 16px; max-width:none; }
details.pn-note{padding:16px}
.pn-note{border-top:8px solid var(--note-color,var(--rule))}
.pn-note summary{cursor:pointer;padding:8px 0}
.pn-body{white-space:pre-wrap;overflow-wrap:anywhere}
.pn-question{border:1px solid var(--rule);padding:16px;margin:16px 0;min-width:0}
/* A long question wraps inside the box instead of across its top border (390 px). */
.pn-question legend{float:left;width:100%;padding:0;margin:0 0 4px;overflow-wrap:anywhere}
.pn-question legend+*{clear:both}
.pn-question label,.pn-editor label{display:block;margin-top:10px}
.pn-editor fieldset.choice label{margin-top:0}
.pn-question textarea,.pn-question select,.pn-editor input:not([type=checkbox]),.pn-editor select{max-width:100%;width:100%;box-sizing:border-box}
@media(max-width:760px){.pn-question{padding:12px}}
.pn-editor fieldset.choice{margin-top:10px}
/* Phone tap floor for the controls app.css does not cover (selects, plain summaries). */
@media(max-width:760px){.pn-question select,.pn-editor select,.pn-note summary{min-height:44px}}
/* A disabled action in the workspace (Approve this snapshot) must not look clickable. */
#pn-workspace button:disabled{opacity:.5;cursor:not-allowed}
/* A refusal right under a count line gets room to breathe (re-engage campaign). */
.pt-k + .pt-notice{margin-top:12px}

