/*
 * TAG Legal Desk v2.1: History (the Director, 28 Sep 2026). The History button in the board head and the wide
 * History panel: search, sort and filters, the list of jobs done, and the read only record of one job.
 * Desk tokens only, so Light, Dark, Eucalypt, Harbour, High contrast and the Canteen themes all hold; the email paper
 * stays white in every theme, as in a job. Nothing animates (no transition moves anything; the desk's reduced motion
 * rules cover the one background fade on hover). 44 px targets, the desk's own focus ring, no page scroll sideways at
 * phone width. A welfare item is outlined calmly, never the solid red of a live alert. No inline styles.
 */

/* ---------- the button in the board head ---------- */
.v21h-btn { min-height: 44px; }
.v21h-btn .ico { color: var(--brand-text); }

/* ---------- the panel: the desk's sheet, expanded wide ---------- */
.sheet.v21h-sheet { width: min(1180px, 100%); }
.v21h { display: grid; gap: 16px; min-width: 0; }
.v21h-view { display: grid; gap: 14px; min-width: 0; }
.v21h-view[hidden], .v21h-none[hidden], .v21h-detail[hidden] { display: none; }

/* search, sort and the Filters button */
.v21h-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; min-width: 0; }
.v21h-field { display: grid; gap: 4px; min-width: 0; }
.v21h-field > label { font-size: .8125rem; font-weight: 700; color: var(--ink-2); }
.v21h-qf { flex: 1 1 320px; }
.v21h-qwrap { position: relative; display: block; min-width: 0; }
.v21h-qwrap > .ico { position: absolute; left: 12px; top: 50%; margin-top: -8px; color: var(--ink-3); pointer-events: none; }
.v21h-search, .v21h-select, .v21h-date {
  min-height: 44px; max-width: 100%; box-sizing: border-box; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--edge-strong); background: var(--solid); color: var(--ink); font: inherit; font-size: .9375rem;
}
.v21h-search { width: 100%; padding-left: 36px; }
.v21h-search::placeholder { color: var(--ink-3); opacity: 1; }
.v21h-select { padding-right: 8px; }
.v21h-search:focus-visible, .v21h-select:focus-visible, .v21h-date:focus-visible { outline-offset: 0; border-color: var(--focus); }
.v21h-ftog { gap: 8px; }
.v21h-ftog .ico { color: var(--brand-text); }
.v21h-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-size: .75rem; font-weight: 700; }
.v21h-badge:empty { display: none; }

/* the filters */
.v21h-filters { display: grid; gap: 14px; padding: 14px 16px; border-radius: 16px; min-width: 0; }
.v21h-filters[hidden] { display: none; }
.v21h-group { display: grid; gap: 6px; min-width: 0; }
.v21h-gl { margin: 0; font-size: .8125rem; font-weight: 700; color: var(--ink-2); }
.v21h-chips { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.v21h-chip { min-height: 44px; }
.v21h-chip .av { box-shadow: none; }
.v21h-chip[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); border-color: var(--brand-text); }
.v21h-switch { display: flex; min-width: 0; }
.v21h-switch .switch { white-space: normal; text-align: left; }
.v21h-dates { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.v21h-kind { max-width: 420px; }
.v21h-wnote { margin: 0; }

/* the count, Clear filters and Refresh */
.v21h-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
.v21h-count { margin: 0; margin-right: auto; font-weight: 600; color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.v21h-count.v21h-err { color: var(--danger); }
.v21h-status .btn { min-height: 44px; }
.v21h-status .btn[hidden] { display: none; }

/* ---------- the list ---------- */
.v21h-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 0; }
.v21h-day { margin: 8px 2px 0; }
.v21h-day:first-child { margin-top: 0; }
.v21h-day h3 { margin: 0; font-size: .75rem; line-height: 1rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.v21h-item { position: relative; display: block; min-width: 0; padding: 14px 18px; border-radius: var(--r-card); }
.v21h-item::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--glass-hover); opacity: 0; pointer-events: none; transition: opacity var(--t-small) var(--ease-out); }
.v21h-item:hover::before { opacity: 1; }
.v21h-item.is-welfare::before { display: none; }
/* The full row button sits under the words: its padding edge still opens the record, and the words above it can be
   selected and copied (a plain click on them opens the record too, from the script). */
.v21h-hit { position: absolute; inset: 0; z-index: 0; margin: 0; padding: 0; border: 0; background: transparent; border-radius: inherit; cursor: pointer; }
.v21h-hit:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.v21h-body { position: relative; z-index: 1; display: grid; gap: 6px; min-width: 0; cursor: pointer; }
.v21h-r1 { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
.v21h-head { font-size: 1rem; line-height: 1.4rem; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.v21h-time { flex: none; font-size: .8125rem; color: var(--ink-2); white-space: nowrap; }
.v21h-r2 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .875rem; color: var(--ink-2); min-width: 0; }
.v21h-client { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; }
.v21h-client b { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.v21h-ref, .v21h-id { font-size: .8125rem; color: var(--ink-2); }
.v21h-kindtag { color: var(--ink-2); background: var(--solid-2); }
.v21h-r3 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0; }
.v21h-who { display: inline-flex; align-items: center; gap: 8px; font-size: .875rem; font-weight: 600; min-width: 0; }
.v21h-who > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.v21h-who .av { box-shadow: none; }
.v21h-fred { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); }
.v21h-item.is-fred { box-shadow: inset 3px 0 0 var(--accent), inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), var(--shadow-1); }
.v21h-item.is-welfare { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--welfare-bg) 55%, transparent), inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), var(--shadow-1); }
.v21h-nosend { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .875rem; color: var(--ink-2); }
.v21h-mails { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 4px; min-width: 0; }
.v21h-mail { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; font-size: .875rem; }
.v21h-to { flex: 1 1 auto; min-width: 0; }
.v21h-to b { font-weight: 600; }
.v21h-subj { color: var(--ink-2); }
.v21h-st { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.v21h-st-sent { color: var(--ok); background: color-mix(in srgb, var(--ok) var(--tint-alpha), transparent); }
.v21h-st-back { color: var(--warn); background: color-mix(in srgb, var(--warn) var(--tint-alpha), transparent); }
.v21h-st-fail { color: var(--danger); background: color-mix(in srgb, var(--danger) var(--tint-alpha), transparent); }
.v21h-st-off { color: var(--ink-2); background: var(--solid-2); }
.v21h-st-wait { color: var(--info); background: color-mix(in srgb, var(--info) var(--tint-alpha), transparent); }
.v21h-ups { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .8125rem; color: var(--ink-2); min-width: 0; }
.v21h-ups .ico { flex: none; color: var(--ink-3); }
.v21h-more { display: flex; justify-content: center; min-height: 0; }
.v21h-more .btn { min-width: 200px; }
.v21h-more .meta { margin: 0; }

/* not built yet: one plain line */
.v21h-none { display: grid; gap: 8px; }
.v21h-none .meta { margin: 0; }

/* ---------- the record of one job ---------- */
.v21h-detail { display: grid; gap: 14px; min-width: 0; }
.v21h-back { justify-self: start; min-height: 44px; }
.v21h-dh { margin: 4px 0 0; font-size: 1.25rem; line-height: 1.625rem; font-weight: 700; overflow-wrap: anywhere; }
.v21h-dmeta { margin: -6px 0 0; color: var(--ink-2); font-size: .875rem; overflow-wrap: anywhere; }
.v21h-by { margin: 0; }
.v21h-sec { display: grid; gap: 10px; min-width: 0; }
.v21h-sec > h4 { margin: 6px 0 0; font-size: .75rem; line-height: 1rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.v21h-what { margin: 0; font-size: 1rem; line-height: 1.5rem; font-weight: 600; overflow-wrap: anywhere; }
.v21h-sec p { overflow-wrap: anywhere; }
.v21h-src, .v21h-email { display: grid; gap: 8px; padding: 14px 16px; border-radius: 16px; min-width: 0; }
.v21h-eh { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; min-width: 0; }
.v21h-eh b { overflow-wrap: anywhere; min-width: 0; }
.v21h-addr, .v21h-subjline { margin: 0; overflow-wrap: anywhere; }
.v21h-subjline { font-weight: 700; }
.v21h-text { display: grid; gap: 8px; min-width: 0; }
.v21h-text p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9375rem; line-height: 1.45rem; }
.v21h-ehead { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 0; font-size: .875rem; }
.v21h-ehead dt { color: var(--ink-3); font-weight: 700; }
.v21h-ehead dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.v21h-paper { display: grid; gap: 8px; padding: 14px 16px; border-radius: 12px; background: var(--paper); color: var(--paper-ink); border: 1px solid var(--glass-rim); font-size: .9375rem; line-height: 1.45rem; min-width: 0; }
.v21h-paper p, .v21h-paper ul, .v21h-paper ol, .v21h-paper dl, .v21h-paper blockquote { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.v21h-paper ul, .v21h-paper ol { padding-left: 22px; white-space: normal; }
.v21h-bh { font-weight: 700; }
.v21h-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; white-space: normal; }
.v21h-facts dt { font-weight: 700; }
.v21h-facts dd { margin: 0; min-width: 0; }
.v21h-quote { padding-left: 12px; border-left: 3px solid var(--edge-strong); font-style: italic; }
.v21h-files { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.v21h-files .file { max-width: 100%; }
.v21h-files .file .ico { color: var(--ink-3); }
.v21h-footer { font-size: .8125rem; color: var(--ink-2); }
.v21h-footer summary { cursor: pointer; font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.v21h-upl { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.v21h-up { display: flex; align-items: flex-start; gap: 8px; font-size: .9375rem; overflow-wrap: anywhere; }
.v21h-up .ico { flex: none; margin-top: 3px; color: var(--ok); }
.v21h-up.is-skipped .ico, .v21h-up.is-off .ico { color: var(--ink-3); }
.v21h-up.is-failed .ico { color: var(--danger); }
.v21h-tl { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.v21h-tl > li { display: grid; grid-template-columns: minmax(0, 150px) 24px minmax(0, 1fr); align-items: center; gap: 10px; font-size: .9375rem; }
.v21h-tl .av { box-shadow: none; }
.v21h-tlt { font-size: .8125rem; color: var(--ink-2); }
.v21h-tlx { min-width: 0; overflow-wrap: anywhere; }
.v21h-dot { width: 10px; height: 10px; margin: 0 7px; border-radius: 50%; background: var(--edge-strong); }

/* ---------- phone width ---------- */
@media (max-width: 599px) {
  .v21h-sheet .sheet-b { padding-left: 16px; padding-right: 16px; }
  .v21h-bar { align-items: stretch; }
  .v21h-bar > .v21h-field, .v21h-bar > .v21h-ftog { flex: 1 1 100%; }
  .v21h-select, .v21h-date { width: 100%; }
  .v21h-filters { padding: 12px; }
  .v21h-item { padding: 12px 14px; }
  .v21h-r1 { flex-wrap: wrap; }
  .v21h-mail { flex-wrap: wrap; }
  .v21h-to.ell { white-space: normal; }
  .v21h-ups .ell { white-space: normal; }
  .v21h-tl > li { grid-template-columns: 24px minmax(0, 1fr); }
  .v21h-tlt { grid-column: 1 / -1; }
  .v21h-ehead, .v21h-facts { grid-template-columns: minmax(0, 1fr); }
  .v21h-ehead dd { margin-bottom: 4px; }
}

/* ---------- High contrast and forced colours ---------- */
:root[data-theme="high_contrast"] .v21h-search, :root[data-theme="high_contrast"] .v21h-select, :root[data-theme="high_contrast"] .v21h-date { border: 2px solid #000; }
:root[data-theme="high_contrast"] .v21h-chip[aria-pressed="true"] { outline: 3px solid #000; outline-offset: -3px; background: #E6E6E6; color: #000; }
:root[data-theme="high_contrast"] .v21h-item, :root[data-theme="high_contrast"] .v21h-src, :root[data-theme="high_contrast"] .v21h-email { border: 2px solid #000; }
:root[data-theme="high_contrast"] .v21h-item.is-fred, :root[data-theme="high_contrast"] .v21h-item.is-welfare { box-shadow: inset 5px 0 0 #000; }
:root[data-theme="high_contrast"] .v21h-paper { border: 2px solid #000; }
:root[data-theme="high_contrast"] .v21h-st { border: 2px solid currentColor; }
:root[data-theme="high_contrast"] .v21h-fred { border: 2px solid #000; background: #fff; color: #000; }
:root[data-theme="high_contrast"] .v21h-badge { border: 2px solid #000; }
@media (forced-colors: active) {
  .v21h-item, .v21h-src, .v21h-email, .v21h-paper, .v21h-filters { border: 1px solid CanvasText; }
  .v21h-chip[aria-pressed="true"] { outline: 2px solid Highlight; }
  .v21h-st, .v21h-badge, .v21h-fred { border: 1px solid CanvasText; }
}

/* ---------- reduced motion: the hover fade goes too ---------- */
@media (prefers-reduced-motion: reduce) { :root:not([data-motion="full"]) .v21h-item::before { transition: none; } }
:root[data-motion="reduced"] .v21h-item::before, :root[data-calm="on"] .v21h-item::before { transition: none; }
