/* ============================================================================
   K9LogPro — Canonical primitive library (UI overhaul epic #835, Phase 3, #842)
   ----------------------------------------------------------------------------
   The single, Bootstrap-INDEPENDENT `.k9-*` component layer — the ~12 doc-25 §5
   primitives + the chart sub-primitives + the recurring composite blocks. This
   is the reusable vocabulary Phase-4 page restyles adopt.

   ARCHITECTURE (locked, doc 25 §8.4 Phase-3 decision):
   1. Purely ADDITIVE. Defining `.k9-*` classes changes the appearance of ZERO
      existing pages — nothing today carries a `.k9-*` class except the gallery
      at /admin/design-system. Bootstrap stays for the grid / utilities / JS only.
   2. Token-driven. Every color references a `--k9-*` custom property from the
      Phase-1 token sheet (css/k9-design-system.css) — never a raw hex / rgb()
      literal (pinned by Design_system_stylesheet_uses_tokens_not_raw_hex). One
      theme switch ([data-bs-theme]) recolors the whole layer.
   3. Zero-leak / single-vocabulary. EVERY selector is `.k9-*`-scoped — no bare
      element selectors (`button`, `table`, `input`) and no Bootstrap-class
      selectors (`.btn`, `.card`, `.badge`). A bare/Bootstrap selector would leak
      onto existing pages and break guarantee #1 (pinned by
      Primitive_layer_is_namespaced_and_does_not_restyle_bootstrap). Interactive
      primitives that are usually <button>s reset their own border/background/font
      so they never depend on a global element reset.

   Loaded from App.razor AFTER k9-design-system.css (so it sees the tokens) and
   BEFORE app.css. The Phase-1 `--bs-*` bridge is the PERMANENT Bootstrap↔token
   integration layer (NOT a removable shim) — Phase 4 shipped every page, yet the
   app deliberately keeps `.form-check` / `.alert` / grid + utilities on Bootstrap,
   so the bridge keeps that markup on-palette forever. See doc 25 §8.4 / #901.

   A11y (doc 25 §7): every interactive primitive shows a visible accent focus ring
   (:focus-visible); status colors pair with a text label + dot (color is never the
   only signal); hover-lift + skeleton shimmer honour prefers-reduced-motion. Both
   light and dark verified via the gallery.
   ============================================================================ */


/* ============================================================================
   1. BUTTON — .k9-btn (+ -primary / -ghost / -split / size modifiers)
   ============================================================================ */
.k9-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--k9-radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1;
  color: var(--k9-text);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s, color .15s;
}
.k9-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.k9-btn:active { transform: translateY(1px); }
.k9-btn:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 2px; }
.k9-btn:disabled,
.k9-btn.k9-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.k9-btn-primary {
  background: var(--k9-accent);
  color: var(--k9-on-accent);
  box-shadow: 0 4px 12px var(--k9-ring);
}
.k9-btn-primary:hover { background: var(--k9-accent-press); box-shadow: 0 8px 20px var(--k9-ring); }

.k9-btn-ghost {
  background: var(--k9-surface);
  color: var(--k9-text-2);
  border: 1px solid var(--k9-hairline);
}
.k9-btn-ghost:hover { color: var(--k9-text); border-color: var(--k9-hairline-strong); box-shadow: var(--k9-shadow-sm); }

/* Destructive variant — a ghost-shaped button tinted with the semantic red token
   (delete / deactivate / purge actions). */
.k9-btn-danger {
  background: var(--k9-surface);
  color: var(--k9-red);
  border: 1px solid var(--k9-hairline);
}
.k9-btn-danger:hover { color: var(--k9-red); border-color: var(--k9-red); background: var(--k9-red-bg); }

/* Split button — a primary action with a divided caret affordance. */
.k9-btn-split { padding-right: 11px; }
.k9-btn .k9-caret-sep {
  margin-left: 4px;
  padding-left: 9px;
  border-left: 1px solid color-mix(in srgb, var(--k9-on-accent) 28%, transparent);
  display: inline-flex;
  align-items: center;
}

/* Size modifiers (used by card/table action rows). */
.k9-btn-sm { height: 34px; padding: 0 13px; font-size: 12.5px; border-radius: var(--k9-radius-sm); }
.k9-btn-xs { height: 30px; padding: 0 11px; font-size: 12px; border-radius: var(--k9-radius-sm); }

@media (prefers-reduced-motion: reduce) {
  .k9-btn { transition: background .15s, border-color .15s, color .15s; }
  .k9-btn:active { transform: none; }
}


/* ============================================================================
   2. CARD — .k9-card (hover-lift) + .k9-panel (flush, non-lifting container)
   ============================================================================ */
.k9-card {
  position: relative;
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  padding: 18px;
  box-shadow: var(--k9-shadow-sm);
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.k9-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--k9-shadow-lift);
  border-color: var(--k9-hairline-strong);
}
/* Static container variant — opt OUT of the lift (forms, info panels in a grid). */
.k9-card.k9-card-static { transition: none; }
.k9-card.k9-card-static:hover { transform: none; box-shadow: var(--k9-shadow-sm); border-color: var(--k9-hairline); }
.k9-card-flush { padding: 0; overflow: hidden; }

.k9-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.k9-card-head-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.k9-card-head-sub { color: var(--k9-text-3); font-size: 12px; font-weight: 500; margin-top: 2px; }
/* Chevron CTA in a card / panel header. */
.k9-card-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--k9-accent-text);
  text-decoration: none;
  transition: gap .15s, color .15s;
}
.k9-card-link svg { width: 14px; height: 14px; }
.k9-card-link:hover { gap: 8px; color: var(--k9-accent-text-press); }

/* Flush panel — head + body, used for tables / lists / settings panels. */
.k9-panel {
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  box-shadow: var(--k9-shadow-sm);
  overflow: hidden;
}
.k9-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--k9-hairline);
}
.k9-panel-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; flex: 1; }
.k9-panel-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--k9-accent-text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}
.k9-panel-link svg { width: 14px; height: 14px; }
.k9-panel-link:hover { color: var(--k9-accent-text-press); }
.k9-count-pill {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--k9-text-2);
  background: var(--k9-surface-2);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-pill);
  padding: 3px 10px;
}
.k9-panel-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--k9-surface-2);
  border-top: 1px solid var(--k9-hairline);
}

@media (prefers-reduced-motion: reduce) {
  .k9-card { transition: box-shadow .2s ease, border-color .2s ease; }
  .k9-card:hover { transform: none; }
}


/* ============================================================================
   3. BADGE / STATUS PILL — .k9-badge (+ semantic variants) + role sub-family
   ============================================================================ */
.k9-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--k9-radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
}
.k9-badge .k9-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.k9-badge-green   { background: var(--k9-green-bg);   color: var(--k9-green); }
.k9-badge-green   .k9-dot { background: var(--k9-green); }
.k9-badge-amber   { background: var(--k9-amber-bg);   color: var(--k9-amber); }
.k9-badge-amber   .k9-dot { background: var(--k9-amber); }
.k9-badge-neutral { background: var(--k9-neutral-bg); color: var(--k9-neutral); }
.k9-badge-neutral .k9-dot { background: var(--k9-neutral); }
.k9-badge-red     { background: var(--k9-red-bg);     color: var(--k9-red); }
.k9-badge-red     .k9-dot { background: var(--k9-red); }
.k9-badge-accent  { background: var(--k9-accent-soft); color: var(--k9-accent-text); }
.k9-badge-accent  .k9-dot { background: var(--k9-accent); }

/* Role badges (MembershipRole). Owner / Trainer / Assistant reuse the accent /
   green / neutral tokens; Admin uses the dedicated --k9-role-admin pair (which
   carries its own dark override in the token sheet — no per-theme rule here). */
.k9-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: var(--k9-radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
}
.k9-role-badge .k9-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; }
.k9-role-owner     { background: var(--k9-accent-soft);    color: var(--k9-accent-text); }
.k9-role-owner     .k9-dot { background: var(--k9-accent); }
.k9-role-admin     { background: var(--k9-role-admin-bg);  color: var(--k9-role-admin); }
.k9-role-admin     .k9-dot { background: var(--k9-role-admin); }
.k9-role-trainer   { background: var(--k9-green-bg);       color: var(--k9-green); }
.k9-role-trainer   .k9-dot { background: var(--k9-green); }
.k9-role-assistant { background: var(--k9-neutral-bg);     color: var(--k9-neutral); }
.k9-role-assistant .k9-dot { background: var(--k9-neutral); }


/* ============================================================================
   4. CHIP — filter chip group / favourite trigger / removable tag
   ============================================================================ */
.k9-chip-group {
  display: inline-flex;
  gap: 6px;
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-pill);
  padding: 4px;
  box-shadow: var(--k9-shadow-sm);
}
.k9-chip {
  padding: 6px 15px;
  border-radius: var(--k9-radius-pill);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--k9-text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.k9-chip:hover { color: var(--k9-text); }
.k9-chip.k9-active { background: var(--k9-accent); color: var(--k9-on-accent); }
.k9-chip:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 2px; }

.k9-chip-fav {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--k9-radius-pill);
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--k9-text-2);
  box-shadow: var(--k9-shadow-sm);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.k9-chip-fav:hover { color: var(--k9-text); border-color: var(--k9-hairline-strong); }
.k9-chip-fav:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 2px; }
.k9-chip-fav svg { width: 15px; height: 15px; color: var(--k9-text-3); }
.k9-chip-fav.k9-on svg { color: var(--k9-fav); fill: var(--k9-fav); }

/* Removable token (lesson-plan sub-types, instructors, etc.). */
.k9-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 6px 0 13px;
  border-radius: var(--k9-radius-pill);
  background: var(--k9-accent-soft);
  color: var(--k9-accent-text);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--k9-accent) 22%, transparent);
}
.k9-tag-x {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--k9-accent-text);
  cursor: pointer;
  transition: background .15s;
}
.k9-tag-x:hover { background: color-mix(in srgb, var(--k9-accent) 16%, transparent); }
.k9-tag-x:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 1px; }
.k9-tag-x svg { width: 12px; height: 12px; }
.k9-tag.k9-tag-person {
  background: var(--k9-surface-2);
  color: var(--k9-text);
  border: 1px solid var(--k9-hairline);
  padding-left: 5px;
}
.k9-tag.k9-tag-person .k9-tag-x { color: var(--k9-text-3); }
.k9-tag.k9-tag-person .k9-tag-x:hover { background: var(--k9-hairline); }
.k9-tag-ava {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex: 0 0 auto;
  color: var(--k9-on-accent);
  font-weight: 700;
  font-size: 10.5px;
  display: grid;
  place-items: center;
  background: var(--k9-avatar-grad);
}
/* Dashed "add" affordance alongside a tag group. */
.k9-add-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 12px;
  border-radius: var(--k9-radius-pill);
  background: var(--k9-surface-2);
  border: 1px dashed var(--k9-hairline-strong);
  color: var(--k9-text-3);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.k9-add-input:hover { color: var(--k9-accent-text); border-color: var(--k9-accent); }
.k9-add-input:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 2px; }
.k9-add-input svg { width: 14px; height: 14px; }


/* ============================================================================
   5. TABLE — .k9-table-wrap + .k9-table (uppercase head, row tints, foot/pager)
   ============================================================================ */
.k9-table-wrap {
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  box-shadow: var(--k9-shadow-sm);
  overflow: hidden;
}
/* Wide tables scroll horizontally inside their wrapper on narrow viewports. */
.k9-table-scroll { overflow-x: auto; }
.k9-table { width: 100%; border-collapse: collapse; }
.k9-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--k9-text-3);
  padding: 14px 18px;
  background: var(--k9-surface-2);
  border-bottom: 1px solid var(--k9-hairline);
}
.k9-table tbody td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--k9-hairline);
  vertical-align: middle;
  font-size: 13.5px;
}
.k9-table tbody tr { transition: background .12s; }
.k9-table tbody tr:last-child td { border-bottom: none; }
.k9-table tbody tr:hover { background: var(--k9-surface-2); }
/* Row state tints (signed / draft) — color paired with the status badge in-row. */
.k9-table tbody tr.k9-is-signed { background: color-mix(in srgb, var(--k9-green) 7%, var(--k9-surface)); }
.k9-table tbody tr.k9-is-signed:hover { background: color-mix(in srgb, var(--k9-green) 12%, var(--k9-surface)); }
.k9-table tbody tr.k9-is-draft { background: color-mix(in srgb, var(--k9-amber) 8%, var(--k9-surface)); }
.k9-table tbody tr.k9-is-draft:hover { background: color-mix(in srgb, var(--k9-amber) 13%, var(--k9-surface)); }

/* Cell helpers. */
.k9-t-name { font-weight: 700; }
.k9-t-muted { color: var(--k9-text-2); }
.k9-t-dog { display: flex; align-items: center; gap: 11px; }
.k9-t-actions { display: flex; gap: 6px; justify-content: flex-end; }
.k9-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.k9-t-fav {
  color: var(--k9-text-3);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
}
.k9-t-fav:hover { background: var(--k9-surface); }
.k9-t-fav:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 1px; }
.k9-t-fav.k9-on { color: var(--k9-fav); }
.k9-t-fav.k9-on svg { fill: var(--k9-fav); }

/* Footer + pager. */
.k9-table-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-top: 1px solid var(--k9-hairline);
  background: var(--k9-surface-2);
  font-size: 12.5px;
  color: var(--k9-text-3);
  font-weight: 600;
}
.k9-pager { display: inline-flex; gap: 6px; margin-left: auto; }
.k9-pager-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--k9-radius-sm);
  border: 1px solid var(--k9-hairline);
  background: var(--k9-surface);
  color: var(--k9-text-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, border-color .15s, background .15s;
}
.k9-pager-btn:hover { color: var(--k9-accent-text); border-color: var(--k9-hairline-strong); }
.k9-pager-btn.k9-active { background: var(--k9-accent); color: var(--k9-on-accent); border-color: var(--k9-accent); }
.k9-pager-btn:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 2px; }
.k9-pager-btn:disabled { opacity: .5; cursor: not-allowed; }


/* ============================================================================
   6. FORM FIELD — .k9-field / .k9-input / .k9-select (+ decorators)
   ============================================================================ */
.k9-field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.k9-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.k9-field.k9-col-2 { grid-column: span 2; }
.k9-field.k9-col-full { grid-column: 1 / -1; }
.k9-field label,
.k9-label { font-size: 12px; font-weight: 700; color: var(--k9-text-2); letter-spacing: .01em; }
.k9-req { color: var(--k9-accent-text); margin-left: 1px; }
.k9-hint { font-size: 11.5px; color: var(--k9-text-3); }

.k9-input,
.k9-select,
.k9-textarea {
  width: 100%;
  height: 42px;
  border-radius: var(--k9-radius-md);
  background: var(--k9-surface-2);
  border: 1px solid var(--k9-hairline);
  padding: 0 14px;
  color: var(--k9-text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.k9-textarea { height: auto; min-height: 92px; padding: 11px 14px; line-height: 1.5; resize: vertical; }
.k9-input:focus,
.k9-select:focus,
.k9-textarea:focus {
  outline: none;
  border-color: var(--k9-accent);
  box-shadow: 0 0 0 4px var(--k9-ring);
  background: var(--k9-surface);
}
.k9-input::placeholder,
.k9-textarea::placeholder { color: var(--k9-text-3); }
.k9-input:disabled,
.k9-select:disabled,
.k9-textarea:disabled { opacity: .6; cursor: not-allowed; }

.k9-select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer; }
.k9-select-wrap { position: relative; }
.k9-select-wrap .k9-chev {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--k9-text-3);
  pointer-events: none;
}
/* Trailing-unit + leading-icon decorators. */
.k9-input-suffix { position: relative; }
.k9-input-suffix .k9-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--k9-text-3);
}
.k9-input-suffix .k9-input { padding-right: 54px; }
.k9-input-ico { position: relative; }
.k9-input-ico .k9-lead {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--k9-text-3);
}
.k9-input-ico .k9-input { padding-left: 38px; }


/* ============================================================================
   7. SWITCH / TOGGLE — .k9-toggle (38×21 track, 17px knob)
   ============================================================================ */
.k9-toggle {
  position: relative;
  width: 38px;
  height: 21px;
  border-radius: var(--k9-radius-pill);
  border: none;
  padding: 0;
  background: var(--k9-hairline-strong);
  cursor: pointer;
  transition: background .2s;
  flex: 0 0 auto;
}
.k9-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--k9-on-accent);
  box-shadow: var(--k9-shadow-sm);
  transition: transform .2s;
}
.k9-toggle.k9-on { background: var(--k9-accent); }
.k9-toggle.k9-on::after { transform: translateX(17px); }
.k9-toggle:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 2px; }

/* Label + state text alongside a toggle. */
.k9-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--k9-text-2);
  user-select: none;
}
.k9-switch .k9-sw-state { min-width: 24px; color: var(--k9-text); font-size: 12px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .k9-toggle, .k9-toggle::after { transition: none; }
}


/* ============================================================================
   8. SEGMENTED CONTROL — .k9-segmented / .k9-seg (role=tablist)
   ============================================================================ */
.k9-segmented {
  display: inline-flex;
  background: var(--k9-surface-2);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-md);
  padding: 3px;
  gap: 2px;
}
.k9-seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--k9-radius-sm);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--k9-text-2);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.k9-seg svg { width: 15px; height: 15px; }
.k9-seg:hover { color: var(--k9-text); }
.k9-seg.k9-active,
.k9-seg[aria-selected="true"] { background: var(--k9-surface); color: var(--k9-accent-text); box-shadow: var(--k9-shadow-sm); }
.k9-seg:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 2px; }


/* ============================================================================
   9. STAT / KPI TILE — .k9-stat (+ delta) and .k9-kpi (+ trend)
   ============================================================================ */
.k9-stat {
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  padding: 18px;
  box-shadow: var(--k9-shadow-sm);
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.k9-stat:hover { transform: translateY(-3px); box-shadow: var(--k9-shadow-lift); border-color: var(--k9-hairline-strong); }
.k9-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--k9-radius-md);
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  background: var(--k9-accent-soft);
  color: var(--k9-accent-text);
}
.k9-stat-icon svg { width: 21px; height: 21px; }
.k9-stat-icon.k9-green   { color: var(--k9-green);   background: var(--k9-green-bg); }
.k9-stat-icon.k9-amber   { color: var(--k9-amber);   background: var(--k9-amber-bg); }
.k9-stat-icon.k9-red     { color: var(--k9-red);     background: var(--k9-red-bg); }
.k9-stat-icon.k9-neutral { color: var(--k9-neutral); background: var(--k9-neutral-bg); }
.k9-stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.k9-stat-label { color: var(--k9-text-2); font-size: 13px; font-weight: 500; margin-top: 3px; }
.k9-stat-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 11px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--k9-radius-pill);
}
.k9-stat-delta svg { width: 13px; height: 13px; }
.k9-delta-up   { background: var(--k9-green-bg);   color: var(--k9-green); }
.k9-delta-down { background: var(--k9-red-bg);     color: var(--k9-red); }
.k9-delta-flat { background: var(--k9-neutral-bg); color: var(--k9-neutral); }
.k9-delta-note { color: var(--k9-text-3); font-size: 11.5px; font-weight: 500; margin-left: 6px; }

/* KPI variant — top icon + label + big value + text trend (reports archetype). */
.k9-kpi {
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  padding: 18px;
  box-shadow: var(--k9-shadow-sm);
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.k9-kpi:hover { transform: translateY(-3px); box-shadow: var(--k9-shadow-lift); border-color: var(--k9-hairline-strong); }
.k9-kpi-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.k9-kpi-ic {
  width: 36px;
  height: 36px;
  border-radius: var(--k9-radius-md);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--k9-accent-soft);
  color: var(--k9-accent-text);
}
.k9-kpi-ic svg { width: 18px; height: 18px; }
.k9-kpi-ic.k9-green { background: var(--k9-green-bg); color: var(--k9-green); }
.k9-kpi-ic.k9-amber { background: var(--k9-amber-bg); color: var(--k9-amber); }
.k9-kpi-ic.k9-red   { background: var(--k9-red-bg);   color: var(--k9-red); }
.k9-kpi-label { font-size: 12px; font-weight: 600; color: var(--k9-text-3); text-transform: uppercase; letter-spacing: .05em; }
.k9-kpi-val { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.k9-kpi-val span { font-size: 16px; font-weight: 700; color: var(--k9-text-2); margin-left: 1px; }
.k9-kpi-trend { display: inline-flex; align-items: center; gap: 4px; margin-top: 9px; font-size: 12px; font-weight: 600; }
.k9-kpi-trend svg { width: 13px; height: 13px; }
.k9-kpi-trend.k9-up   { color: var(--k9-green); }
.k9-kpi-trend.k9-down { color: var(--k9-red); }
.k9-kpi-trend.k9-flat { color: var(--k9-text-3); }

@media (prefers-reduced-motion: reduce) {
  .k9-stat, .k9-kpi { transition: box-shadow .2s ease, border-color .2s ease; }
  .k9-stat:hover, .k9-kpi:hover { transform: none; }
}


/* ============================================================================
   10. PAGE HEADER — .k9-page-head / breadcrumb / pill sub-tabs
   ============================================================================ */
/* flex-wrap (#1205): the action cluster's buttons cannot shrink below their min-content
   width, so on a narrow viewport a crowded header overflowed and scrolled the WHOLE page
   sideways. Wrapping drops the actions onto a second row (the existing `gap` supplies the
   row gap) instead. No effect at widths where the header already fits on one line. */
.k9-page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
/* min-width:0 lets a long title shrink so its text wraps, rather than forcing the line
   wider than the viewport on its own. */
.k9-page-head h1,
.k9-page-head .k9-page-title { min-width: 0; }
.k9-page-head h1,
.k9-page-title { font-size: 26px; font-weight: 800; letter-spacing: -.025em; }
.k9-ph-spacer { flex: 1; }

.k9-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--k9-text-3);
  font-weight: 500;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.k9-breadcrumb a { color: var(--k9-text-2); text-decoration: none; transition: color .15s; }
.k9-breadcrumb a:hover { color: var(--k9-accent-text); }
.k9-breadcrumb svg { width: 14px; height: 14px; color: var(--k9-text-3); }
.k9-crumb-current { color: var(--k9-text); font-weight: 600; }

.k9-subtabs {
  display: inline-flex;
  gap: 4px;
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-pill);
  padding: 5px;
  box-shadow: var(--k9-shadow-sm);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.k9-subtab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--k9-radius-pill);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--k9-text-2);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.k9-subtab svg { width: 15px; height: 15px; }
.k9-subtab:hover { color: var(--k9-text); }
.k9-subtab.k9-active,
.k9-subtab[aria-selected="true"] { background: var(--k9-accent); color: var(--k9-on-accent); }
.k9-subtab:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 2px; }


/* ============================================================================
   11. AVATAR — .k9-avatar monogram block (+ sizes + favourite-star overlay)
   ----------------------------------------------------------------------------
   The canonical gradient-monogram primitive. The existing image-backed
   PersonAvatar / DogAvatar / OrganizationLogo components are NOT restyled here
   (they keep their per-identity hues + the docs/18 §16 circle/square shapes and
   migrate in Phase 4) — this is the additive vocabulary Phase-4 pages adopt.
   ============================================================================ */
.k9-avatar {
  width: 54px;
  height: 54px;
  border-radius: var(--k9-radius-md);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--k9-avatar-grad);
  color: var(--k9-on-accent);
  font-weight: 800;
  font-size: 22px;
  box-shadow: var(--k9-shadow-sm);
  text-transform: uppercase;
  user-select: none;
}
.k9-avatar-sm { width: 30px; height: 30px; border-radius: 50%; font-size: 12px; font-weight: 700; }
.k9-avatar-xs { width: 34px; height: 34px; border-radius: var(--k9-radius-sm); font-size: 14px; font-weight: 700; }
.k9-avatar-lg { width: 78px; height: 78px; border-radius: 18px; font-size: 30px; }

.k9-avatar-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
.k9-avatar-fav {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--k9-hairline);
  background: var(--k9-surface);
  color: var(--k9-text-3);
  display: grid;
  place-items: center;
  box-shadow: var(--k9-shadow-sm);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.k9-avatar-fav:hover { color: var(--k9-text-2); border-color: var(--k9-hairline-strong); }
.k9-avatar-fav:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 1px; }
.k9-avatar-fav svg { width: 13px; height: 13px; }
.k9-avatar-fav.k9-on { color: var(--k9-fav); }
.k9-avatar-fav.k9-on svg { fill: var(--k9-fav); }


/* ============================================================================
   12. EMPTY & SKELETON STATES (designed in Phase 3 — doc 25 §5 row 12 / §8.4)
   ----------------------------------------------------------------------------
   Empty = icon + message + CTA slot; the consuming page supplies the localized
   strings (these hardcode nothing). Skeleton = shimmer placeholders. Both honour
   prefers-reduced-motion.
   ============================================================================ */
.k9-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 48px 24px;
}
.k9-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--k9-radius-lg);
  display: grid;
  place-items: center;
  background: var(--k9-surface-2);
  border: 1px solid var(--k9-hairline);
  color: var(--k9-text-3);
}
.k9-empty-icon svg { width: 26px; height: 26px; }
.k9-empty-title { font-size: 16px; font-weight: 700; color: var(--k9-text); letter-spacing: -.01em; }
.k9-empty-text { font-size: 13.5px; color: var(--k9-text-2); max-width: 42ch; line-height: 1.55; }
.k9-empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }

.k9-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--k9-surface-2);
  border-radius: var(--k9-radius-sm);
}
.k9-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--k9-hairline) 70%, transparent), transparent);
  animation: k9-skeleton-shimmer 1.4s ease-in-out infinite;
}
.k9-skeleton-line { height: 12px; border-radius: var(--k9-radius-pill); margin-bottom: 9px; }
.k9-skeleton-line.k9-short { width: 60%; }
.k9-skeleton-line:last-child { margin-bottom: 0; }
.k9-skeleton-circle { border-radius: 50%; }
.k9-skeleton-block { border-radius: var(--k9-radius-md); }

@keyframes k9-skeleton-shimmer {
  100% { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .k9-skeleton::after { animation: none; }
}


/* ============================================================================
   CHART SUB-PRIMITIVES (doc 25 §5 — analytics archetype, pure CSS/SVG)
   ----------------------------------------------------------------------------
   These coexist with Blazor-ApexCharts; Phase 4e decides per chart which to use.
   SVG presentation classes drive stroke/fill from tokens; a consuming SVG that
   uses .k9-area-fill must define <linearGradient id="k9-area-grad">.
   ============================================================================ */
/* Vertical bars */
.k9-chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; height: 172px; }
.k9-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px; height: 100%; justify-content: flex-end; }
.k9-bar-track { width: 100%; display: flex; align-items: flex-end; justify-content: center; flex: 1; }
.k9-bar {
  width: 60%;
  max-width: 38px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--k9-accent), var(--k9-accent-grad-2));
  box-shadow: 0 4px 10px var(--k9-ring);
  position: relative;
  transition: filter .15s, transform .15s;
}
.k9-bar:hover { filter: brightness(1.08); }
.k9-bar-val { position: absolute; top: -21px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--k9-text-2); white-space: nowrap; }
.k9-bar-label { font-size: 11.5px; font-weight: 600; color: var(--k9-text-3); }
.k9-chart-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--k9-hairline);
  color: var(--k9-text-2);
  font-size: 12.5px;
}
.k9-chart-foot svg { width: 14px; height: 14px; color: var(--k9-accent-text); }
.k9-chart-foot b { color: var(--k9-text); font-weight: 700; }

/* Area / line */
.k9-area-chart { width: 100%; height: auto; display: block; overflow: visible; }
.k9-area-grid { stroke: var(--k9-hairline); stroke-width: 1; }
.k9-area-axis { fill: var(--k9-text-3); font-size: 11px; font-weight: 600; font-family: var(--k9-font); }
.k9-area-fill { fill: url(#k9-area-grad); }
.k9-area-line { fill: none; stroke: var(--k9-accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.k9-area-dot { fill: var(--k9-surface); stroke: var(--k9-accent); stroke-width: 2.5; }
.k9-area-dot-peak { fill: var(--k9-accent); stroke: var(--k9-surface); stroke-width: 2.5; }

/* Horizontal bars */
.k9-hbars { display: flex; flex-direction: column; gap: 15px; padding-top: 2px; }
.k9-hbar-row { display: grid; grid-template-columns: 104px 1fr 38px; align-items: center; gap: 12px; }
.k9-hbar-label { font-size: 12.5px; font-weight: 600; color: var(--k9-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k9-hbar-track { height: 14px; border-radius: var(--k9-radius-pill); background: var(--k9-surface-2); border: 1px solid var(--k9-hairline); overflow: hidden; }
.k9-hbar-fill { height: 100%; border-radius: var(--k9-radius-pill); background: linear-gradient(90deg, var(--k9-accent), var(--k9-accent-grad-2)); transition: width .6s cubic-bezier(.4, 0, .2, 1); }
.k9-hbar-val { font-size: 12.5px; font-weight: 700; color: var(--k9-text); text-align: right; }

/* Donut + legend */
.k9-donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.k9-donut { flex: 0 0 auto; }
.k9-donut-center { fill: var(--k9-text); font-weight: 800; font-size: 22px; font-family: var(--k9-font); text-anchor: middle; }
.k9-donut-center-sub { fill: var(--k9-text-3); font-weight: 600; font-size: 10px; letter-spacing: .06em; text-anchor: middle; }
.k9-legend { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 130px; }
.k9-legend-row { display: flex; align-items: center; gap: 10px; }
.k9-legend-sw { width: 11px; height: 11px; border-radius: 4px; flex: 0 0 auto; }
.k9-legend-name { font-size: 13px; font-weight: 600; color: var(--k9-text-2); flex: 1; }
.k9-legend-val { font-size: 13px; font-weight: 700; color: var(--k9-text); }

/* Inline pass-rate progress cell */
.k9-pass-cell { display: flex; align-items: center; gap: 10px; min-width: 130px; }
.k9-pass-track { flex: 1; height: 7px; border-radius: var(--k9-radius-pill); background: var(--k9-surface-2); border: 1px solid var(--k9-hairline); overflow: hidden; }
.k9-pass-fill { height: 100%; border-radius: var(--k9-radius-pill); background: var(--k9-green); }
.k9-pass-fill.k9-amber { background: var(--k9-amber); }
.k9-pass-fill.k9-red { background: var(--k9-red); }
.k9-pass-pct { font-size: 12.5px; font-weight: 700; width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .k9-bar, .k9-hbar-fill { transition: none; }
}


/* ============================================================================
   COMPOSITE BLOCKS (doc 25 §5 — built from the primitives, not new primitives)
   ============================================================================ */
/* Profile / entity hero header (avatar + fact grid + action stack). */
.k9-hero {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  padding: 22px;
  box-shadow: var(--k9-shadow-sm);
  margin-bottom: 22px;
}
.k9-hero-main { flex: 1; min-width: 240px; }
.k9-hero-name-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.k9-hero-name { font-size: 23px; font-weight: 800; letter-spacing: -.025em; }
.k9-hero-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--k9-text-2); font-size: 13.5px; }
.k9-hero-meta strong { color: var(--k9-text); font-weight: 700; }
.k9-hero-meta .k9-dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--k9-text-3); }
.k9-hero-actions { display: flex; flex-direction: column; gap: 10px; flex: 0 0 auto; align-self: flex-start; }

/* Fact grid (label/value pairs). */
.k9-fact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px 22px; }
.k9-fact { display: flex; flex-direction: column; gap: 2px; }
.k9-fact-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--k9-text-3); }
.k9-fact-value { font-size: 13.5px; font-weight: 600; color: var(--k9-text); }
.k9-fact-value.k9-mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.k9-fact-sub { color: var(--k9-text-3); font-weight: 500; }

/* Compact hero variant (DogShell — doc 25 § 6.3). The persistent hero shrinks on the
   satellite routes: it keeps Pic + Name + Breed + a mini fact line (Sex/Age/Colour) while
   the full .k9-hero-collapse fact grid tweens away (grid-rows 1fr↔0fr, jank-free), and the
   avatar scales via a wrapper transform (leaves the shared <DogAvatar> geometry untouched).
   Token-only + fully namespaced under .k9-hero (single-vocabulary, § 8.4). */
.k9-hero { transition: padding .26s cubic-bezier(.4, 0, .2, 1), gap .26s cubic-bezier(.4, 0, .2, 1); }
.k9-hero-name { transition: font-size .26s cubic-bezier(.4, 0, .2, 1); }
.k9-hero-avatar { flex: 0 0 auto; }
/* Breed line — collapsible so the narrow scrolled band can drop it (grid-rows tween). */
.k9-hero-breed { display: grid; grid-template-rows: 1fr; opacity: 1;
  transition: grid-template-rows .28s cubic-bezier(.4, 0, .2, 1), opacity .2s ease; }
.k9-hero-breed > * { overflow: hidden; min-height: 0; }
.k9-hero-collapse { display: grid; grid-template-rows: 1fr; opacity: 1; margin-top: 12px;
  transition: grid-template-rows .28s cubic-bezier(.4, 0, .2, 1), opacity .2s ease, margin-top .26s ease; }
.k9-hero-collapse > * { overflow: hidden; min-height: 0; }
.k9-hero-mini { display: grid; grid-template-rows: 0fr; opacity: 0; margin-top: 0;
  transition: grid-template-rows .28s cubic-bezier(.4, 0, .2, 1), opacity .2s ease, margin-top .26s ease; }
.k9-hero-mini > * { overflow: hidden; min-height: 0; }
.k9-mini-facts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 18px; font-size: 13px; }
.k9-mini-fact { display: inline-flex; align-items: baseline; gap: 6px; }
.k9-mini-fact-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--k9-text-3); }
.k9-mini-fact-value { color: var(--k9-text); font-weight: 700; }

/* Narrow-band one-line summary (Breed · Age · Sex) — collapsed at rest; the DogShell scroll
   animation reveals it on the minimized band (grid-rows 0fr->1fr + fade). One line, truncates. */
.k9-hero-narrow { display: grid; grid-template-rows: 0fr; opacity: 0; margin-top: 0;
  transition: grid-template-rows .28s cubic-bezier(.4, 0, .2, 1), opacity .2s ease, margin-top .26s ease; }
.k9-hero-narrow > * { overflow: hidden; min-height: 0; }
.k9-hero-narrow-line { font-size: 12.5px; color: var(--k9-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k9-narrow-dot { color: var(--k9-text-3); margin: 0 6px; }

.k9-hero.k9-compact { padding: 15px 20px; gap: 18px; }
/* The avatar box resize lives in DogShell.razor.css (::deep the child DogAvatar — the xl
   chip is 192px, so we resize its real box, not a transform). */
.k9-hero.k9-compact .k9-hero-name { font-size: 20px; }
.k9-hero.k9-compact .k9-hero-collapse { grid-template-rows: 0fr; opacity: 0; margin-top: 0; }
.k9-hero.k9-compact .k9-hero-mini { grid-template-rows: 1fr; opacity: 1; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .k9-hero, .k9-hero-name, .k9-hero-collapse, .k9-hero-mini, .k9-hero-breed, .k9-hero-narrow { transition: none; }
}

/* Activity / feed item. */
.k9-feed-row { display: flex; align-items: center; gap: 13px; padding: 12px 0; border-top: 1px solid var(--k9-hairline); }
.k9-feed-row:first-child { border-top: none; }
.k9-feed-main { flex: 1; min-width: 0; }
.k9-feed-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.k9-feed-name { font-weight: 700; font-size: 14px; }
.k9-feed-sub { color: var(--k9-text-2); font-size: 12.5px; margin-top: 2px; }
.k9-feed-date { color: var(--k9-text-3); font-size: 12px; white-space: nowrap; flex: 0 0 auto; }

/* Needs-attention item. */
.k9-na { display: flex; align-items: flex-start; gap: 12px; padding: 12px 13px; border-radius: var(--k9-radius-md); border: 1px solid var(--k9-hairline); background: var(--k9-surface-2); transition: border-color .15s, background .15s; }
.k9-na:hover { border-color: var(--k9-hairline-strong); background: var(--k9-surface); }
.k9-na-icon { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; display: grid; place-items: center; background: var(--k9-amber-bg); color: var(--k9-amber); }
.k9-na-icon.k9-red { background: var(--k9-red-bg); color: var(--k9-red); }
.k9-na-icon svg { width: 16px; height: 16px; }
.k9-na-body { flex: 1; min-width: 0; }
.k9-na-title { font-weight: 700; font-size: 13.5px; }
.k9-na-desc { color: var(--k9-text-2); font-size: 12.5px; margin-top: 2px; }

/* Toolbar (filter / view-switch strip). */
.k9-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  padding: 14px 18px;
  box-shadow: var(--k9-shadow-sm);
}
.k9-tb-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--k9-text-3); }
.k9-tb-spacer { flex: 1; }

/* Form card (a section of a multi-step form). */
.k9-form-card {
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  box-shadow: var(--k9-shadow-sm);
  padding: 20px 22px;
}
.k9-fc-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.k9-fc-icon { width: 38px; height: 38px; border-radius: var(--k9-radius-md); flex: 0 0 auto; background: var(--k9-accent-soft); color: var(--k9-accent-text); display: grid; place-items: center; }
.k9-fc-icon svg { width: 19px; height: 19px; }
.k9-fc-title { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.k9-fc-sub { font-size: 12.5px; color: var(--k9-text-3); margin-top: 2px; line-height: 1.45; }
.k9-fc-step { margin-left: auto; flex: 0 0 auto; font-size: 11px; font-weight: 700; color: var(--k9-text-3); background: var(--k9-surface-2); border: 1px solid var(--k9-hairline); border-radius: var(--k9-radius-pill); padding: 4px 11px; }

/* Sticky form footer with live summary. */
.k9-form-footer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--k9-surface) 90%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  padding: 14px 18px;
  box-shadow: var(--k9-shadow-md);
}
.k9-form-footer .k9-summary { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--k9-text-3); font-weight: 600; }
.k9-form-footer .k9-summary svg { width: 15px; height: 15px; color: var(--k9-accent-text); }
.k9-form-footer .k9-summary b { color: var(--k9-text-2); }
.k9-ff-spacer { flex: 1; }

/* Settings sub-nav rail. */
.k9-subnav {
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  box-shadow: var(--k9-shadow-sm);
  padding: 8px;
}
.k9-subnav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--k9-radius-sm);
  color: var(--k9-text-2);
  font-weight: 500;
  font-size: 13.5px;
  text-decoration: none;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.k9-subnav-item:last-child { margin-bottom: 0; }
.k9-subnav-item svg { flex: 0 0 auto; width: 17px; height: 17px; }
.k9-subnav-item:hover { background: var(--k9-surface-2); color: var(--k9-text); }
.k9-subnav-item.k9-active { background: var(--k9-accent-soft); color: var(--k9-accent-text); font-weight: 600; }
.k9-sn-chev { margin-left: auto; color: var(--k9-text-3); opacity: 0; }
.k9-subnav-item.k9-active .k9-sn-chev { color: var(--k9-accent-text); opacity: 1; }

/* Setting row (label + control). */
.k9-setting-row {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--k9-hairline);
}
.k9-setting-row:last-of-type { border-bottom: none; }
.k9-sr-label { flex: 1; min-width: 0; }
.k9-sr-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.k9-sr-help { color: var(--k9-text-3); font-size: 12.5px; margin-top: 3px; max-width: 46ch; }
.k9-sr-control { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }

/* Scoring matrix shell (dogs × sub-types) + 1–5 pip score control. */
.k9-matrix-scroll { overflow-x: auto; }
.k9-matrix { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 760px; }
.k9-matrix th, .k9-matrix td { padding: 0; }
.k9-matrix thead th {
  background: transparent;
  border: none;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--k9-text-2);
  padding: 0 8px 12px;
  text-align: center;
  vertical-align: bottom;
}
.k9-matrix thead th.k9-corner { text-align: left; color: var(--k9-text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; min-width: 190px; }
.k9-matrix tbody td { padding: 7px 8px; border-bottom: 1px solid var(--k9-hairline); }
.k9-matrix tbody tr:last-child td { border-bottom: none; }
.k9-matrix-row-dog { display: flex; align-items: center; gap: 11px; min-width: 190px; }
.k9-matrix-row-dog .k9-nm { font-weight: 700; font-size: 13.5px; }
.k9-matrix-row-dog .k9-hd { font-size: 11px; color: var(--k9-text-3); }
.k9-score { display: inline-flex; gap: 3px; padding: 3px; border-radius: var(--k9-radius-sm); background: var(--k9-surface-2); border: 1px solid var(--k9-hairline); }
.k9-pip {
  width: 20px;
  height: 26px;
  border-radius: 6px;
  border: none;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--k9-text-3);
  background: transparent;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.k9-pip:hover { color: var(--k9-text-2); background: var(--k9-surface); }
.k9-pip.k9-on { background: var(--k9-accent); color: var(--k9-on-accent); box-shadow: 0 2px 6px var(--k9-ring); }
/* Low score (1–2): amber fill. The text must be the DARK amber companion, not white —
   in dark mode --k9-amber flips to a light tint (#f0bb5b) and white-on-amber falls below
   AA. --k9-amber-bg on the --k9-amber fill clears AA in both themes (~4.6:1 light after
   the 2026-07-10 --amber darkening, ~8.4:1 dark), mirroring the badge text/-bg pairing.
   doc 25 § 7 (#842 a11y review + 2026-07-10 contrast audit). */
.k9-pip.k9-on.k9-lo { background: var(--k9-amber); color: var(--k9-amber-bg); }
.k9-pip.k9-empty { opacity: .55; }
.k9-pip:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 1px; }
.k9-cell-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 34px;
  border-radius: var(--k9-radius-sm);
  border: 1px dashed var(--k9-hairline-strong);
  color: var(--k9-text-3);
  font-size: 12px;
  font-weight: 600;
}
.k9-matrix-note {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--k9-radius-md);
  background: var(--k9-accent-soft);
  color: var(--k9-accent-text);
  font-size: 12.5px;
  font-weight: 600;
}
.k9-matrix-note svg { width: 16px; height: 16px; flex: 0 0 auto; }


/* ============================================================================
   13. MODAL / DIALOG — .k9-modal-backdrop (scrim) + .k9-modal-dialog / -panel
   The app's dialogs are Blazor `@if`-rendered overlays — no Bootstrap JS: the
   parent toggles a `_show…` flag and @onclick handlers close/confirm. These
   primitives replace the (bridged) Bootstrap `.modal` / `.modal-dialog` /
   `.modal-content` chrome 1:1 (same nesting), so a migration is a pure class
   swap with byte-identical @code. The backdrop is the scrim + centering layer;
   the panel is the surface. doc 25 §5 row 13.
   ============================================================================ */
.k9-modal-backdrop {
  position: fixed;
  inset: 0;
  /* Out-ranks the shell off-canvas drawer (1085) + its scrim (1080) + the
     sticky top bar (1020), so a dialog always sits above the app chrome. */
  z-index: 1090;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(24px, 4vh) 16px 24px;
  overflow-y: auto;
  background: var(--k9-scrim);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: k9-modal-fade .16s ease;
}
.k9-modal-dialog { width: 100%; max-width: 520px; margin: auto; }
.k9-modal-dialog.k9-modal-sm { max-width: 400px; }
.k9-modal-dialog.k9-modal-lg { max-width: 780px; }
.k9-modal-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  background: var(--k9-surface);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-lg);
  box-shadow: var(--k9-shadow-lift);
  animation: k9-modal-rise .18s cubic-bezier(.4, 0, .2, 1);
}
.k9-modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--k9-hairline);
}
.k9-modal-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; color: var(--k9-text); }
/* Icon-only close (×). The button carries its own aria-label in markup; the glyph
   is drawn in CSS so the migration stays a pure class swap on the empty button. */
.k9-modal-close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--k9-radius-sm);
  background: transparent;
  color: var(--k9-text-3);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .12s, color .12s;
}
.k9-modal-close::before { content: "\00D7"; }
.k9-modal-close:hover { background: var(--k9-surface-2); color: var(--k9-text); }
.k9-modal-close:focus-visible { outline: 2px solid var(--k9-accent); outline-offset: 1px; }
.k9-modal-close:disabled { opacity: .5; cursor: default; }
.k9-modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px; }
.k9-modal-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid var(--k9-hairline);
}
@keyframes k9-modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes k9-modal-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .k9-modal-backdrop, .k9-modal-panel { animation: none; }
}


/* ============================================================================
   14. READING PROSE — .k9-prose (the rendered-Markdown container: /help
       articles + /changelog). doc 25 §5 / §6.1 (A9 "Reading / system").
       ONE canonical primitive so help + changelog share a single measured,
       tokenized reading surface (the .k9-modal precedent — a recurring surface
       is a primitive, not duplicated per-page scoped ::deep CSS). Comfortable
       ~70ch measure, heading scale, accent links, and tokenized code /
       blockquote / table / image styling — theme-aware for free.
   ============================================================================ */
.k9-prose {
  max-width: 72ch;
  color: var(--k9-text);
  font-size: 14.5px;
  line-height: 1.65;
  overflow-wrap: break-word;
}
.k9-prose > :first-child { margin-top: 0; }
.k9-prose > :last-child { margin-bottom: 0; }

.k9-prose h1 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--k9-text);
  margin: 0 0 .7rem;
}
.k9-prose h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--k9-text);
  margin: 2rem 0 .8rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--k9-hairline);
}
.k9-prose h3 {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--k9-text);
  margin: 1.6rem 0 .5rem;
}
.k9-prose h4,
.k9-prose h5,
.k9-prose h6 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--k9-text);
  margin: 1.3rem 0 .4rem;
}

.k9-prose p { margin: 0 0 1rem; }
.k9-prose ul,
.k9-prose ol { margin: 0 0 1rem; padding-left: 1.4rem; }
.k9-prose li { margin-bottom: .35rem; line-height: 1.6; }
.k9-prose li > ul,
.k9-prose li > ol { margin: .35rem 0 0; }

/* In-body prose links stay underlined at rest — they sit inside running text, so
   colour alone is not a sufficient cue (WCAG 1.4.1). (UI-chrome links — breadcrumb,
   card-link — may be colour-only; they are isolated, not embedded in a paragraph.) */
.k9-prose a {
  color: var(--k9-accent-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.k9-prose a:hover { color: var(--k9-accent-text-press); }

.k9-prose strong { font-weight: 700; color: var(--k9-text); }

.k9-prose code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .875em;
  background: var(--k9-surface-2);
  border: 1px solid var(--k9-hairline);
  border-radius: 5px;
  padding: .1em .35em;
}
.k9-prose pre {
  background: var(--k9-surface-2);
  border: 1px solid var(--k9-hairline);
  border-radius: var(--k9-radius-sm);
  padding: .85rem 1rem;
  overflow-x: auto;
  margin: 0 0 1rem;
}
.k9-prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: .85em;
}

.k9-prose blockquote {
  border-left: 3px solid var(--k9-accent);
  background: var(--k9-surface-2);
  color: var(--k9-text-2);
  padding: .5rem .9rem;
  margin: 0 0 1rem;
  border-radius: 0 var(--k9-radius-sm) var(--k9-radius-sm) 0;
}
.k9-prose blockquote > :last-child { margin-bottom: 0; }

.k9-prose table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 1rem;
  font-size: .92em;
}
.k9-prose th,
.k9-prose td {
  border: 1px solid var(--k9-hairline);
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
}
.k9-prose thead th {
  background: var(--k9-surface-2);
  font-weight: 700;
  color: var(--k9-text);
}
/* #588 T16 / D2: a cookie name in a table cell (`.AspNetCore.Antiforgery.*`) must not set the
   table's width. Only code breaks anywhere; `anywhere` on every cell (a68ba86e) split ordinary
   words mid-letter at phone width, also in a Help table that already fit. #588 D3 (Re-run 2): on
   a phone the cells hyphenate (below), and code must not get hyphens that are not part of the
   name, so a cookie name breaks without an inserted hyphen. */
.k9-prose td code { overflow-wrap: anywhere; hyphens: manual; -webkit-hyphens: manual; }
@media (max-width: 576px) {
  /* Phone: hyphenate long words (the article carries lang="en|hu|fr"), and if a
     word still cannot fit, let the table scroll inside itself, never the page. */
  .k9-prose td, .k9-prose th { hyphens: auto; -webkit-hyphens: auto; }
  .k9-prose table { display: block; overflow-x: auto; }
}

.k9-prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--k9-radius-sm);
  border: 1px solid var(--k9-hairline);
  margin: .5rem 0;
}
.k9-prose hr {
  border: 0;
  border-top: 1px solid var(--k9-hairline);
  margin: 1.5rem 0;
}


/* ============================================================================
   RESPONSIVE — the doc-25 §4.4 breakpoints, applied to the primitive grids.
   ============================================================================ */
@media (max-width: 1024px) {
  .k9-field-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .k9-field-grid { grid-template-columns: 1fr; }
  .k9-field.k9-col-2 { grid-column: span 1; }
  .k9-setting-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .k9-form-footer .k9-summary { display: none; }
}
