/* Component library (HCK-U04). Every screen is built from these; the live
   reference is /styleguide. Blue is the main accent (actions, links, focus),
   gold the secondary one (counts, highlights; always a fill behind ink text). */

/* ---- text roles ---- */
.eyebrow { font-size: var(--text-xs); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.display { font-size: var(--text-3xl); line-height: .96; font-weight: 800; letter-spacing: -0.045em; text-wrap: balance; }
.title { font-style: italic; font-weight: 700; letter-spacing: -0.02em; }
.lede { font-size: var(--text-lg); line-height: 1.45; color: var(--ink-2); max-width: 46ch; }
.mute { color: var(--mute); }
.small { font-size: var(--text-sm); }
.reading { font-size: 1.1875rem; line-height: 1.7; max-width: var(--measure); }
.reading > * + * { margin-top: 1.1em; }
.hl { background: linear-gradient(transparent 58%, var(--gold) 58%, var(--gold) 92%, transparent 92%); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.link { font-weight: 700; color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); border-top: var(--rule-heavy) solid var(--ink); padding-top: var(--s-3); margin-bottom: var(--s-2); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-5);
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: transparent; color: var(--ink);
  font: inherit; font-weight: 800; font-size: 15px; letter-spacing: -0.005em;
  text-decoration: none; cursor: pointer; transition: background var(--ease), color var(--ease);
}
.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent); color: var(--on-accent); filter: brightness(1.12); }
.btn--danger { border-color: var(--no); color: var(--no); }
.btn--danger:hover { background: var(--no); color: var(--paper); }
.btn--quiet { border-color: transparent; text-decoration: underline; text-underline-offset: 4px; }
.btn--quiet:hover { background: transparent; color: var(--accent); }
.btn--sm { min-height: 36px; padding: 0 var(--s-4); font-size: var(--text-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--text-xs); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.field-hint { font-size: var(--text-sm); color: var(--mute); }
.field-error { font-size: var(--text-sm); font-weight: 700; color: var(--no); }
.field-error::before { content: "\25A0\00a0"; }
.input, .select, .textarea, .field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="search"], .field input[type="url"], .field input[type="number"], .field input[type="date"], .field select, .field textarea {
  width: 100%; min-height: 44px; padding: var(--s-2) var(--s-3);
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font: inherit;
}
.textarea, .field textarea { padding: var(--s-4); line-height: 1.65; min-height: 8rem; }
.input[aria-invalid="true"], .field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--no); }
.check { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.form-stack { display: flex; flex-direction: column; gap: var(--s-5); max-width: 560px; }

/* ---- feedback ---- */
.alert { padding: var(--s-3) var(--s-4); border: 2px solid currentColor; border-radius: var(--radius); font-weight: 700; display: flex; gap: var(--s-3); }
.alert::before { content: "\25A0"; flex: none; }
.alert--ok { color: var(--ok); background: var(--ok-bg); }
.alert--wait { color: var(--wait); background: var(--wait-bg); }
.alert--no { color: var(--no); background: var(--no-bg); }
.pill { display: inline-flex; align-items: center; gap: var(--s-2); height: 26px; padding: 0 10px; font-size: var(--text-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; border-radius: var(--radius); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; background: currentColor; }
.pill--ok { color: var(--ok); background: var(--ok-bg); }
.pill--wait { color: var(--wait); background: var(--wait-bg); }
.pill--no { color: var(--no); background: var(--no-bg); }
.pill--stale { color: var(--stale); background: var(--stale-bg); }
.tag { display: inline-block; padding: 2px 10px; border: 1.5px solid var(--ink); font-size: 13px; font-weight: 700; border-radius: var(--radius); }
.badge { display: inline-block; min-width: 22px; padding: 1px 7px; text-align: center; background: var(--gold); color: var(--on-gold); font-size: var(--text-xs); font-weight: 800; border-radius: var(--radius); }
.empty { padding: var(--s-6) 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); color: var(--mute); }
.empty strong { display: block; color: var(--ink); font-size: var(--text-lg); letter-spacing: -0.015em; margin-bottom: var(--s-1); }

/* ---- containers ---- */
.card { border: 2px solid var(--ink); padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.card--soft { border: 0; background: var(--paper-2); }
.card--danger { border-color: var(--no); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); }

.tabs { display: flex; flex-wrap: wrap; gap: var(--s-5) 28px; border-bottom: 1px solid var(--rule); }
.tab { padding: 10px 0; font-weight: 700; color: var(--mute); text-decoration: none; border-bottom: 4px solid transparent; margin-bottom: -1px; }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 800; }
.tab:hover { color: var(--ink); }

.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-6); }
.fig { border-top: var(--rule-heavy) solid var(--ink); padding-top: var(--s-3); }
.fig-n { font-size: 5.25rem; line-height: 1; font-weight: 900; letter-spacing: -0.05em; }
.fig-l { margin-top: var(--s-2); font-size: var(--text-sm); font-weight: 700; }

.figs--compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s-5); }
.figs--compact .fig-n { font-size: 2.75rem; }
/* label comes first in the DOM (screen readers), number first on screen */
.fig--dl { display: flex; flex-direction: column-reverse; }
dl.figs dd { margin: 0; }
/* A figure that turns red only while it is non-zero (real task failures). */
.fig--alert { border-top-color: var(--no); }
.fig--alert .fig-n { color: var(--no); }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--s-7) 64px; align-items: start; }
.split > section { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }

.letter { margin: 0; padding: var(--s-4) var(--s-5); border: 2px solid var(--ink); border-radius: var(--radius); font: inherit; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px var(--s-4); font-size: 15px; }
.kv dt { padding-top: 3px; font-size: var(--text-xs); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }

.rows { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); padding: 14px 0; border-bottom: 1px solid var(--rule); }
.row-main { min-width: 0; }
a.row { color: inherit; text-decoration: none; }
a.row:hover { background: var(--paper-2); }
.row-count { flex: none; width: 72px; font-size: 2.75rem; line-height: 1; font-weight: 900; letter-spacing: -0.05em; }
.row--docket { justify-content: flex-start; gap: var(--s-4); }
.row--docket .pill { margin-left: auto; }

.row-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.row-meta { font-size: var(--text-sm); color: var(--mute); }

.scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; white-space: nowrap; padding: 0 var(--s-4) var(--s-2) 0; border-bottom: 2px solid var(--ink); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.tbl td:nth-child(2) { min-width: 9rem; }
.tbl td { padding: 14px var(--s-4) 14px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl .r { text-align: right; }

.filters { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.filters > summary { display: flex; align-items: center; min-height: 44px; font-weight: 800; cursor: pointer; list-style: none; }
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; }
.filters[open] > summary::after { content: "\2212"; }
.filters-body { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: flex-end; padding: var(--s-2) 0 var(--s-5); }
.filters-body .field { flex: 1 1 220px; }

.pagination { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 var(--s-3); border: 2px solid var(--ink); border-radius: var(--radius); font-weight: 800; text-decoration: none; color: var(--ink); }
.pagination a:hover { background: var(--ink); color: var(--paper); }
.pagination [aria-current="page"] { background: var(--ink); color: var(--paper); }
.pagination .gap { border-color: transparent; }

.timeline { display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--rule); }
.timeline time { font-size: var(--text-sm); font-weight: 700; color: var(--mute); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); }
.toolbar .grow { flex: 1 1 auto; }

@media (max-width: 760px) {
  .fig-n { font-size: 3.5rem; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: var(--s-3); }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* Wide tables scroll sideways inside their own box, never the page. */
.tbl-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl a.sort { color: inherit; text-decoration: none; }
.tbl a.sort:hover, .tbl a.sort[aria-sort] { color: var(--ink); text-decoration: underline; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-4) var(--s-5); }
.form-grid .span-full { grid-column: 1 / -1; }
fieldset.group { border: 0; border-top: 2px solid var(--ink); margin: var(--s-6) 0 0; padding: var(--s-4) 0 0; min-width: 0; }
fieldset.group > legend { padding: 0 var(--s-3) 0 0; font-size: var(--text-xs); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.piece-body { margin: 0; padding: var(--s-5); background: var(--paper-text); border: 2px solid var(--ink); border-radius: var(--radius); font: inherit; font-size: 17px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 68ch; }
.field > label.check { font-size: 15px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink); }

/* Confirm dialog (HCK-U04). */
dialog.modal { max-width: min(30rem, calc(100vw - 2 * var(--page-pad))); padding: var(--s-5); border: 4px solid var(--ink); border-radius: var(--radius); background: var(--paper); color: var(--ink); }
dialog.modal::backdrop { background: rgb(0 0 0 / .55); }
.modal-msg { margin: 0 0 var(--s-4); font-size: var(--text-lg, 1.125rem); font-weight: 700; }

/* Motion and print (HCK-U06). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .sidenav, .skip-link, .actions, .filters, .pagination, .btn, form button, dialog { display: none !important; }
  body, .main { background: #fff !important; color: #000 !important; padding: 0 !important; }
  .main { max-width: none; }
  .letter, .piece-body { border: 0; padding: 0; background: none; font-family: Georgia, "Times New Roman", serif; font-size: 12pt; line-height: 1.5; max-width: none; }
  a { color: inherit; text-decoration: none; }
}

/* Queue card: headline left, letter right, details under the headline; on a phone the
   actions (letter, approve) come before the long detail lists. */
@media (min-width: 900px) {
  .split--card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .split--card > section:nth-child(1) { grid-column: 1; grid-row: 1; }
  .split--card > section:nth-child(2) { grid-column: 2; grid-row: 1 / span 2; }
  .split--card > section.card-details { grid-column: 1; grid-row: 2; }
}
.tbl td.tbl-date { white-space: nowrap; }
