/* ============================================================================
   Phersona Design System — components.css
   Built against tokens.css. Zero hardcoded hex — every colour is a var(--token),
   so every component themes for free in light and dark.

   Conventions:
   · Class prefix  ph-  (avoids collisions when consumed in a real app).
   · Focus is ONE clean line — never a doubled border + offset ring.
       inputs : border-color -> --focus-ring + 1px inset of the same colour
       others : outline 2px solid --focus-ring, offset 2px
   · Full interaction-state set on every interactive component
     (default / hover / focus-visible / active / selected / disabled / loading / error).
   · Colour never carries meaning alone — every status pairs colour with icon/dot/label.
   · Numerics use .tabular (tabular-nums). Layout uses logical properties for RTL.
   · Flat at rest; shadow only on float (dropdowns, popovers, dialogs, toasts, palette).
   Read order mirrors components/: buttons · forms · badges · navigation · overlays ·
   feedback · data-display · signatures.
   ========================================================================== */

/* ---- shared ---------------------------------------------------------------- */
.ph-ico { font-size: var(--icon-sm); line-height: 1; flex: none; display: inline-flex; }
.ph-ico--xs { font-size: var(--icon-xs); }
.ph-ico--md { font-size: var(--icon-md); }
.ph-ico--lg { font-size: var(--icon-lg); }
.ph-ico--xl { font-size: var(--icon-xl); }

.ph-kbd {
  font: var(--weight-regular) var(--text-xs)/1 var(--font-mono);
  color: var(--ink-subtle); font-variant-numeric: tabular-nums;
}

/* The single, consistent keyboard-focus line for non-input controls */
:where(.ph-btn, .ph-icon-btn, .ph-nav-item, .ph-menu-item, .ph-tab, .ph-list-row,
  .ph-link, .ph-tag__remove, .ph-switch, .ph-checkbox, .ph-radio, .ph-cmdk-row,
  .ph-disclosure, .ph-breadcrumb a, .ph-toast__close,
  .ph-option, .ph-day, .ph-page):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;          /* outline follows the element's own radius — don't set radius here */
}

/* ============================================================================
   Typography — the type ramp (Plus Jakarta Sans). Composed text styles you can
   apply to any element to get a role without depending on the tag. The bare
   h1–h4 elements already match .ph-h1…4 (tokens.css base). Pair with .tabular
   (columnar numbers) and .mono (IDs/code) from tokens.css. One family: hierarchy
   is weight + size, never colour or all-caps. 700 is display-only; 600 tops the
   heading ladder.
   ========================================================================== */
.ph-display  { font: var(--weight-bold) var(--text-5xl)/1.05 var(--font-sans); letter-spacing:-.025em; text-wrap:balance; }   /* marketing hero only — ceiling 48px */
.ph-h1       { font: var(--weight-semibold) var(--text-3xl)/1.2 var(--font-sans); letter-spacing:-.02em;  text-wrap:balance; }
.ph-h2       { font: var(--weight-semibold) var(--text-2xl)/1.25 var(--font-sans); letter-spacing:-.015em; text-wrap:balance; }
.ph-h3       { font: var(--weight-semibold) var(--text-xl)/1.3 var(--font-sans); letter-spacing:-.01em; }
.ph-h4       { font: var(--weight-semibold) var(--text-lg)/1.4 var(--font-sans); letter-spacing:-.005em; }
.ph-body-lg  { font: var(--weight-regular) var(--text-md)/1.6 var(--font-sans); }     /* reading body — messages, prose; cap 65–75ch */
.ph-body     { font: var(--weight-regular) var(--text-base)/1.45 var(--font-sans); }  /* default UI body */
.ph-body-sm  { font: var(--weight-regular) var(--text-sm)/1.4 var(--font-sans); }     /* secondary / dense */
/* .ph-label (12/500) is defined with the form controls below */
.ph-caption  { font: var(--weight-regular) var(--text-xs)/1.33 var(--font-sans); color: var(--ink-subtle); }   /* timestamps, meta */
.ph-micro    { font: var(--weight-medium) var(--text-2xs)/1.27 var(--font-sans); letter-spacing:.01em; color: var(--ink-subtle); }  /* dense table micro-meta, sparingly */

/* Text-colour helpers — semantic tiers (never lighten body for "elegance") */
.ph-text-muted  { color: var(--ink-muted); }
.ph-text-subtle { color: var(--ink-subtle); }

/* Long-form reading column + flow */
.ph-prose { max-inline-size: 68ch; }
.ph-prose > * + * { margin-block-start: var(--space-3); }
.ph-prose :where(h2,h3,h4) { text-wrap: balance; margin-block-start: var(--space-6); }

/* Overflow controls — translations expand 30–40%; truncate with a tooltip, never clip silently */
.ph-truncate { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-inline-size:0; }
.ph-clamp-2  { display:-webkit-box; -webkit-line-clamp:2; line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

@keyframes ph-spin { to { transform: rotate(360deg); } }
@keyframes ph-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.ph-spinner {
  inline-size: var(--icon-sm); block-size: var(--icon-sm); flex: none;
  border-radius: var(--radius-full);
  border: 2px solid currentColor;                                  /* fallback if color-mix unsupported */
  border-color: color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  animation: ph-spin .7s linear infinite;
}

/* ============================================================================
   1 · BUTTONS
   ========================================================================== */
.ph-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-block-size: var(--control-md); padding-block: var(--space-1); padding-inline: 14px;
  border: 1px solid transparent; border-radius: var(--radius-md); background: transparent;
  font: var(--weight-medium) var(--text-sm)/1.15 var(--font-sans); color: var(--ink);
  white-space: nowrap; cursor: pointer; user-select: none;
  transition: background var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard),
              transform 80ms var(--ease-standard);
}
.ph-btn:active { transform: scale(.98); }
.ph-btn:disabled, .ph-btn:disabled:hover,
.ph-btn[aria-disabled="true"], .ph-btn[aria-disabled="true"]:hover {   /* :hover listed so disabled never lights up */
  background: var(--disabled-bg); color: var(--disabled-fg);
  border-color: var(--field-border); box-shadow: none; cursor: not-allowed; transform: none;   /* keep a visible edge */
}
.ph-btn--sm { min-block-size: var(--control-sm); padding-inline: var(--space-3); }
.ph-btn--lg { min-block-size: var(--control-lg); padding-inline: var(--space-5); font-size: var(--text-base); }
.ph-btn--lg .ph-ico { font-size: var(--icon-md);     /* 20px icon balances the larger CTA */
  transform: translateY(0.2em); }                     /* seat the taller glyph to the text's optical centre (Tabler em sits high vs the smaller --lg text line) */

.ph-btn--primary { background: var(--accent); color: var(--accent-ink); }
.ph-btn--primary:hover { background: var(--accent-hover); }
.ph-btn--primary:active { background: var(--accent-active); }

.ph-btn--secondary { background: var(--surface); border-color: var(--field-border); color: var(--ink); }
.ph-btn--secondary:hover { background: var(--surface-sunken); }

.ph-btn--ghost { background: transparent; color: var(--ink-muted); }
.ph-btn--ghost:hover { background: var(--surface-sunken);                       /* fallback */
  background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }   /* works on sunken too */

.ph-btn--destructive { background: transparent; color: var(--alert-fg); }
.ph-btn--destructive:hover { background: var(--alert-bg); }
.ph-btn--destructive-solid { background: var(--alert-fg); color: var(--surface); }
.ph-btn--destructive-solid:hover { background: var(--alert-fg);                 /* fallback */
  background: color-mix(in srgb, var(--accent-active) 35%, var(--alert-fg)); }

.ph-btn--ai { background: var(--ai-bg); color: var(--ai-fg); }       /* lavender = AI only */
.ph-btn--ai:hover { background: var(--ai-bg);                                   /* fallback */
  background: color-mix(in srgb, var(--ai-fg) 10%, var(--ai-bg)); }

/* Soft pastel primaries — tint fill + deep same-hue ink (border derived from ink) */
.ph-btn--soft { background: var(--accent-soft); color: var(--accent-soft-ink);
  border-color: var(--border-strong);   /* fallback if color-mix unsupported */
  border-color: color-mix(in srgb, var(--accent-soft-ink) 20%, var(--accent-soft)); }
.ph-btn--soft:hover { background: color-mix(in srgb, var(--accent-soft-ink) 10%, var(--accent-soft)); }
.ph-btn--soft-sage { background: var(--accent-2-soft); color: var(--accent-2-soft-ink);
  border-color: var(--border-strong);
  border-color: color-mix(in srgb, var(--accent-2-soft-ink) 20%, var(--accent-2-soft)); }
.ph-btn--soft-sage:hover { background: color-mix(in srgb, var(--accent-2-soft-ink) 10%, var(--accent-2-soft)); }
.ph-btn--soft-sage:focus-visible { outline-color: var(--accent-2); }   /* sage ring matches the sage button */

/* loading: spinner replaces leading icon, label dims, width held (no reflow).
   In markup, pair aria-busy="true" with aria-disabled="true" so keyboard (Enter/Space)
   activation is blocked too — pointer-events only stops the mouse. */
.ph-btn[aria-busy="true"] { color: color-mix(in srgb, currentColor 55%, transparent); pointer-events: none; }
.ph-btn[aria-busy="true"] .ph-btn__label { opacity: .55; }

.ph-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  inline-size: var(--control-md); block-size: var(--control-md); padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-md);
  background: transparent; color: var(--ink-muted); cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.ph-icon-btn:hover { background: var(--surface-sunken); color: var(--ink); }
.ph-icon-btn--sm { inline-size: var(--control-sm); block-size: var(--control-sm); }
.ph-icon-btn--lg { inline-size: var(--control-lg); block-size: var(--control-lg); }

.ph-btn-group { display: inline-flex; }
.ph-btn-group .ph-btn { border-color: var(--field-border); border-radius: 0; margin-inline-start: -1px; }
.ph-btn-group .ph-btn:first-child { border-start-start-radius: var(--radius-md); border-end-start-radius: var(--radius-md); margin-inline-start: 0; }
.ph-btn-group .ph-btn:last-child { border-start-end-radius: var(--radius-md); border-end-end-radius: var(--radius-md); }
.ph-btn-group .ph-btn[aria-pressed="true"] { background: var(--surface-sunken); color: var(--ink); z-index: 1; }

.ph-link {                                              /* inline-in-text: underlined at rest (WCAG 1.4.1) */
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
  text-decoration-thickness: 1px; font-weight: var(--weight-medium); border-radius: var(--radius-xs);
}
.ph-link:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
.ph-link--bare { text-decoration: none; }               /* standalone / nav links not in a run of text */
.ph-link--bare:hover { text-decoration: underline; }

/* ============================================================================
   2 · FORMS
   ========================================================================== */
.ph-form-field { display: flex; flex-direction: column; gap: var(--space-1); }
.ph-form-field + .ph-form-field { margin-block-start: var(--space-4); }
.ph-label { font: var(--weight-medium) var(--text-xs)/1.3 var(--font-sans); color: var(--ink); }
.ph-label__req { color: var(--ink-subtle); font-weight: var(--weight-regular); }
.ph-hint { font: var(--weight-regular) var(--text-xs)/1.4 var(--font-sans); color: var(--ink-subtle); }
.ph-error {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font: var(--weight-regular) var(--text-xs)/1.4 var(--font-sans); color: var(--alert-fg);
}

/* Form-level error summary — on a failed submit, list every error and link to its
   field (WCAG 3.3.1). Give it role="alert" + tabindex="-1" and move focus to it so
   screen-reader users hear the whole list; each link jumps to the offending control. */
.ph-error-summary {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--alert-bg); color: var(--alert-fg);
  border: 1px solid color-mix(in srgb, var(--alert-fg) 30%, var(--alert-bg));   /* edge survives forced-colors */
}
.ph-error-summary__title { font: var(--weight-semibold) var(--text-sm)/1.3 var(--font-sans); display: inline-flex; align-items: center; gap: var(--space-2); }
.ph-error-summary__list { margin: var(--space-2) 0 0; padding-inline-start: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.ph-error-summary a { color: var(--alert-fg); text-decoration: underline; text-underline-offset: 2px; font-size: var(--text-sm); }

.ph-field {                                              /* soft bordered + calm focus ring */
  inline-size: 100%; min-block-size: var(--control-lg); padding-block: var(--space-2); padding-inline: var(--space-3);
  border: 1px solid var(--field-border); border-radius: var(--radius-field);
  background: var(--surface); color: var(--ink);
  font: var(--weight-regular) var(--text-base)/1.2 var(--font-sans);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.ph-field::placeholder { color: var(--ink-subtle); }
.ph-field:hover { border-color: var(--ink-subtle); }
.ph-field:focus, .ph-field:focus-visible {
  outline: none; border-color: var(--field-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--field-focus) 22%, transparent);   /* soft calm-indigo ring */
}
.ph-field:disabled { background: var(--disabled-bg); color: var(--disabled-fg); border-color: var(--field-border); cursor: not-allowed; }
.ph-field[aria-invalid="true"] { border-color: var(--alert-fg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--alert-fg) 18%, transparent); }   /* soft red ring */
textarea.ph-field { block-size: auto; min-block-size: calc(var(--control-lg) * 1.8); padding-block: var(--space-2); resize: vertical; line-height: 1.45; }
.ph-field--sm { min-block-size: var(--control-md); }
.ph-field--lg { min-block-size: var(--control-lg); }

/* affixes inside the control */
.ph-input-affix { position: relative; display: flex; align-items: center; }
.ph-input-affix .ph-ico { position: absolute; inset-inline-start: var(--space-3); color: var(--ink-muted); pointer-events: none; }
.ph-input-affix .ph-field { padding-inline-start: calc(var(--space-3) * 2 + var(--icon-sm)); }

/* select trigger */
.ph-select { position: relative; display: inline-flex; inline-size: 100%; }
.ph-select select.ph-field { appearance: none; inline-size: 100%; padding-inline-end: calc(var(--space-3) * 2 + var(--icon-sm)); }
.ph-select > .ph-ico { position: absolute; inset-inline-end: var(--space-3); inset-block-start: 50%; transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }

/* checkbox / radio */
.ph-check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; min-block-size: 24px; }
.ph-checkbox, .ph-radio {
  appearance: none; flex: none; inline-size: 16px; block-size: 16px; margin: 0;
  background: var(--surface); border: 1px solid var(--field-border);
  display: inline-grid; place-content: center; cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}
.ph-checkbox { border-radius: var(--radius-xs); }
.ph-radio { border-radius: var(--radius-full); }
.ph-checkbox::after { content: ""; inline-size: 9px; block-size: 9px; transform: scale(0); transform-origin: center;
  clip-path: polygon(14% 44%, 0 60%, 40% 100%, 100% 18%, 86% 4%, 40% 72%);
  background: var(--accent-ink); transition: transform var(--duration-fast) var(--ease-standard); }
.ph-radio::after { content: ""; inline-size: 6px; block-size: 6px; border-radius: var(--radius-full); background: var(--accent-ink); transform: scale(0); transition: transform var(--duration-fast) var(--ease-standard); }
.ph-checkbox:checked, .ph-radio:checked { background: var(--accent); border-color: var(--accent); }
.ph-checkbox:checked::after, .ph-radio:checked::after { transform: scale(1); }
.ph-checkbox:disabled, .ph-radio:disabled { background: var(--disabled-bg); border-color: var(--field-border); cursor: not-allowed; }

/* switch */
.ph-switch { appearance: none; flex: none; inline-size: 32px; block-size: 18px; margin: 0; position: relative;
  background: var(--border-strong); border-radius: var(--radius-full); cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard); }
.ph-switch::after { content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px;
  inline-size: 14px; block-size: 14px; border-radius: var(--radius-full); background: var(--surface);
  transition: transform var(--duration-base) var(--ease-standard); }
.ph-switch:checked { background: var(--accent); }
.ph-switch:checked::after { transform: translateX(14px); }
.ph-switch:disabled { opacity: .5; cursor: not-allowed; }
[dir="rtl"] .ph-switch:checked::after { transform: translateX(-14px); }
/* form controls focus in calm indigo, not rose (rose stays for actions) */
.ph-checkbox:focus-visible, .ph-radio:focus-visible, .ph-switch:focus-visible { outline-color: var(--field-focus); }

/* ============================================================================
   3 · BADGES & STATUS
   ========================================================================== */
.ph-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  min-block-size: 20px; padding-block: 2px; padding-inline: var(--space-2); border-radius: var(--radius-full);
  font: var(--weight-medium) var(--text-xs)/1.2 var(--font-sans);
  background: var(--surface-sunken); color: var(--ink-muted); white-space: nowrap;
}
.ph-badge--ai { background: var(--ai-bg); color: var(--ai-fg); }
.ph-badge--success { background: var(--success-bg); color: var(--success-fg); }
.ph-badge--warning { background: var(--warning-bg); color: var(--warning-fg); }
.ph-badge--alert { background: var(--alert-bg); color: var(--alert-fg); }

.ph-tag {
  display: inline-flex; align-items: center; gap: var(--space-1);
  min-block-size: 22px; padding-block: 3px; padding-inline: var(--space-2); border-radius: var(--radius-sm);
  background: var(--surface-sunken); color: var(--ink-muted);
  font: var(--weight-medium) var(--text-xs)/1.2 var(--font-sans);
}
.ph-tag__remove { display: inline-grid; place-content: center; box-sizing: content-box;
  inline-size: 14px; block-size: 14px; padding: 5px; margin: -5px;   /* 24px hit target (WCAG 2.5.8) */
  border: none; background: transparent; color: inherit; cursor: pointer; border-radius: var(--radius-xs); opacity: .7; }
.ph-tag__remove:hover { opacity: 1; }

.ph-count {
  display: inline-grid; place-content: center; min-inline-size: 16px; min-block-size: 16px;
  padding: 1px 4px; border-radius: var(--radius-full);
  background: var(--accent); color: var(--accent-ink);
  font: var(--weight-medium) var(--text-2xs)/1 var(--font-sans); font-variant-numeric: tabular-nums;
}
.ph-count--muted { background: var(--surface-sunken); color: var(--ink-muted); }

/* status pill — colour + marker + label (Color-Plus-One) */
.ph-pill {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-block-size: 20px; padding-block: 2px; padding-inline: 6px var(--space-2); border-radius: var(--radius-full);
  font: var(--weight-medium) var(--text-xs)/1.2 var(--font-sans); white-space: nowrap;
  background: var(--surface-sunken); color: var(--ink-muted);
}
.ph-pill .ph-dot { inline-size: 6px; block-size: 6px; border-radius: var(--radius-full); background: currentColor; flex: none; }
.ph-pill .ph-dot--hollow { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.ph-pill--prospect { background: var(--avatar-bg); color: var(--avatar-fg); }   /* indigo tint — NOT lavender (that's AI-only) */
.ph-pill--active { background: var(--success-bg); color: var(--success-fg); }
.ph-pill--advocate { background: var(--alert-bg); color: var(--accent); }     /* rose, ★ disambiguates from CTA */
.ph-pill--at-risk { background: var(--warning-bg); color: var(--warning-fg); }
.ph-pill--dormant { background: var(--surface-sunken); color: var(--ink-subtle); }
.ph-pill--churned { background: transparent; color: var(--ink-muted); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* avatar */
.ph-avatar {
  display: inline-grid; place-content: center; flex: none; position: relative;
  inline-size: 32px; block-size: 32px; border-radius: var(--radius-full);
  background: var(--avatar-bg); color: var(--avatar-fg);
  font: var(--weight-semibold) var(--text-xs)/1 var(--font-sans); overflow: hidden;
}
.ph-avatar img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.ph-avatar--xs { inline-size: 20px; block-size: 20px; font-size: var(--text-2xs); }
.ph-avatar--sm { inline-size: 24px; block-size: 24px; }
.ph-avatar--lg { inline-size: 40px; block-size: 40px; font-size: var(--text-sm); }
.ph-avatar--xl { inline-size: 64px; block-size: 64px; font-size: var(--text-xl); }
.ph-avatar--ai { background: var(--ai-bg); color: var(--ai-fg); }       /* concierge mark */
.ph-avatar__presence { position: absolute; inset-block-end: -1px; inset-inline-end: -1px;
  inline-size: 9px; block-size: 9px; border-radius: var(--radius-full); border: 2px solid var(--surface); }
.ph-avatar__presence--online { background: var(--success-fg); }
.ph-avatar__presence--away { background: var(--warning-fg); }
.ph-avatar__presence--offline { background: var(--ink-subtle); }
.ph-avatar-group { display: inline-flex; }
.ph-avatar-group > * { margin-inline-start: -8px; box-shadow: 0 0 0 2px var(--surface); }
.ph-avatar-group > :first-child { margin-inline-start: 0; }

/* ============================================================================
   4 · NAVIGATION
   ========================================================================== */
.ph-sidebar {
  display: flex; flex-direction: column; gap: var(--space-1);
  inline-size: 240px; padding: var(--space-3); background: var(--surface-sunken);
  border-inline-end: 1px solid var(--border);
}
.ph-sidebar__section { margin-block-start: var(--space-3); }
.ph-sidebar__label { padding-inline: var(--space-3); margin-block-end: var(--space-1);
  font: var(--weight-medium) var(--text-xs)/1 var(--font-sans); color: var(--ink-subtle); }

.ph-nav-item {
  position: relative; display: flex; align-items: center; gap: var(--space-2);
  min-block-size: var(--control-md); padding-block: var(--space-1); padding-inline: var(--space-3); border-radius: var(--radius-sm);
  color: var(--ink-muted); font: var(--weight-medium) var(--text-sm)/1.2 var(--font-sans);
  text-decoration: none; cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.ph-nav-item:hover { background: var(--surface-sunken);                         /* fallback */
  background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }   /* visible on the sunken sidebar */
.ph-nav-item .ph-count, .ph-nav-item .ph-badge { margin-inline-start: auto; }
.ph-nav-item[aria-current="page"] { background: var(--surface); color: var(--ink); }
.ph-nav-item[aria-current="page"]::before {        /* inset accent indicator, flips in RTL */
  content: ""; position: absolute; inset-inline-start: 0; inset-block: 5px;
  inline-size: 2px; border-radius: var(--radius-full); background: var(--accent);
}

.ph-topbar {
  display: flex; align-items: center; gap: var(--space-3);
  block-size: 52px; padding-inline: var(--space-4); position: sticky; inset-block-start: 0; z-index: var(--z-sticky);
  background: var(--surface); border-block-end: 1px solid var(--border);
}
.ph-topbar__title { font: var(--weight-semibold) var(--text-base)/1 var(--font-sans); color: var(--ink); }
.ph-topbar__actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--space-2); }

/* tabs — underline that the active indicator slides under */
.ph-tabs { display: flex; gap: var(--space-1); border-block-end: 1px solid var(--border); }
.ph-tab {
  position: relative; appearance: none; border: none; background: transparent; cursor: pointer;
  padding: var(--space-2) var(--space-3); margin-block-end: -1px;
  color: var(--ink-muted); font: var(--weight-medium) var(--text-sm)/1 var(--font-sans);
  transition: color var(--duration-fast) var(--ease-standard);
}
.ph-tab:hover { color: var(--ink); }
.ph-tab[aria-selected="true"] { color: var(--ink); }
.ph-tab[aria-selected="true"]::after {
  content: ""; position: absolute; inset-inline: 0; inset-block-end: 0;
  block-size: 2px; background: var(--accent); border-radius: var(--radius-full) var(--radius-full) 0 0;
}

.ph-breadcrumb { display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); color: var(--ink-muted); }
.ph-breadcrumb a { color: var(--ink-muted); text-decoration: none; }
.ph-breadcrumb a:hover { color: var(--ink); }
.ph-breadcrumb [aria-current="page"] { color: var(--ink); }
.ph-breadcrumb__sep { color: var(--ink-subtle); display: inline-flex; }

/* command palette (signature) */
.ph-cmdk {                                               /* glass — matches the dialog */
  inline-size: min(560px, 92vw);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(30px) saturate(1.4); backdrop-filter: blur(30px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
  padding: var(--space-1); overflow: hidden;
}
.ph-cmdk__input-wrap { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); border-block-end: 1px solid var(--border); }
.ph-cmdk__input-wrap .ph-ico { color: var(--ink-subtle); }
.ph-cmdk__input { flex: 1; border: none; background: transparent; color: var(--ink);
  font: var(--weight-regular) var(--text-md)/1 var(--font-sans); }
.ph-cmdk__input:focus { outline: none; }
.ph-cmdk__list { padding: var(--space-1); max-block-size: 320px; overflow-y: auto; }
.ph-cmdk__group { padding: var(--space-2) var(--space-2) var(--space-1);
  font: var(--weight-medium) var(--text-xs)/1 var(--font-sans); color: var(--ink-subtle); }
.ph-cmdk-row {
  position: relative; display: flex; align-items: center; gap: var(--space-2);
  min-block-size: 36px; padding-block: var(--space-1); padding-inline: var(--space-2); border-radius: var(--radius-md);
  color: var(--ink-muted); font-size: var(--text-sm); cursor: pointer;
}
.ph-cmdk-row .ph-kbd, .ph-cmdk-row__meta { margin-inline-start: auto; }
.ph-cmdk-row[aria-selected="true"] { background: var(--surface-sunken); color: var(--ink); }
.ph-cmdk-row[aria-selected="true"]::before {
  content: ""; position: absolute; inset-inline-start: 0; inset-block: 6px;
  inline-size: 2px; border-radius: var(--radius-full); background: var(--accent);
}

/* ============================================================================
   5 · OVERLAYS
   ========================================================================== */
.ph-scrim { position: fixed; inset: 0; z-index: var(--z-overlay);
  background: var(--overlay); backdrop-filter: blur(4px); }

.ph-tooltip {
  max-inline-size: 240px; padding: var(--space-1) var(--space-2);
  background: var(--ink); color: var(--bg); border-radius: var(--radius-sm);
  font-size: var(--text-xs); line-height: 1.4; box-shadow: var(--shadow-md);
  z-index: var(--z-tooltip);
}

.ph-popover {
  inline-size: max-content; max-inline-size: 320px; padding: var(--space-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); z-index: var(--z-popover);
}

.ph-menu {
  min-inline-size: 200px; padding: var(--space-1);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: var(--z-dropdown);
}
.ph-menu__label { padding: var(--space-2) var(--space-2) var(--space-1);
  font: var(--weight-medium) var(--text-xs)/1 var(--font-sans); color: var(--ink-subtle); }
.ph-menu__divider { block-size: 1px; background: var(--border); margin: var(--space-1) 0; }
.ph-menu-item {
  position: relative; display: flex; align-items: center; gap: var(--space-2);
  min-block-size: var(--control-md); padding-block: var(--space-1); padding-inline: var(--space-2); border-radius: var(--radius-sm);
  color: var(--ink); font-size: var(--text-sm); cursor: pointer; text-decoration: none;
}
.ph-menu-item .ph-kbd { margin-inline-start: auto; }
.ph-menu-item:hover, .ph-menu-item[aria-selected="true"] { background: var(--surface-sunken); }
.ph-menu-item:hover::before, .ph-menu-item[aria-selected="true"]::before {
  content: ""; position: absolute; inset-inline-start: 0; inset-block: 5px;
  inline-size: 2px; border-radius: var(--radius-full); background: var(--accent); }
.ph-menu-item--destructive { color: var(--alert-fg); }
.ph-menu-item--destructive:hover { background: var(--alert-bg); }
.ph-menu-item:disabled, .ph-menu-item[aria-disabled="true"] { color: var(--ink-subtle); cursor: not-allowed; }

.ph-dialog {                                             /* frosted-glass modal — translucent + blur */
  inline-size: min(480px, 92vw); padding: var(--space-6);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(30px) saturate(1.4); backdrop-filter: blur(30px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); z-index: var(--z-modal);
}
.ph-dialog--form { inline-size: min(640px, 92vw); }
.ph-dialog__title { font: var(--weight-semibold) var(--text-xl)/1.3 var(--font-sans); color: var(--ink); margin: 0; }
.ph-dialog__body { margin-block-start: var(--space-2); color: var(--ink-muted); font-size: var(--text-base); line-height: 1.5; }
.ph-dialog__actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-block-start: var(--space-6); }

.ph-sheet {                                              /* glass — matches the dialog */
  position: fixed; inset-block: 0; inset-inline-end: 0; z-index: var(--z-drawer);
  inline-size: min(420px, 92vw); padding: var(--space-6);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(30px) saturate(1.4); backdrop-filter: blur(30px) saturate(1.4);
  box-shadow: var(--shadow-lg);
  border-start-start-radius: var(--radius-xl); border-end-start-radius: var(--radius-xl);
}

/* When .ph-dialog / .ph-sheet / .ph-cmdk are a native <dialog> opened with
   showModal() (behaviors.js), the scrim is the ::backdrop pseudo-element. */
dialog.ph-dialog, dialog.ph-cmdk { color: var(--ink); }
dialog.ph-dialog::backdrop, dialog.ph-sheet::backdrop, dialog.ph-cmdk::backdrop {
  background: var(--overlay); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
dialog.ph-cmdk { padding: var(--space-1); inset-block-start: 12vh; }   /* palette sits high, not dead-centre */
dialog:where(.ph-dialog, .ph-cmdk, .ph-sheet)[open] { display: block; }

/* ============================================================================
   6 · FEEDBACK
   ========================================================================== */
.ph-toast {
  display: flex; align-items: flex-start; gap: var(--space-2);
  max-inline-size: 360px; padding: var(--space-3) var(--space-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); z-index: var(--z-toast);
}
.ph-toast__body { font-size: var(--text-sm); color: var(--ink); line-height: 1.4; }
.ph-toast__close { margin-inline-start: auto; display: inline-grid; place-content: center; box-sizing: content-box;
  inline-size: var(--icon-sm); block-size: var(--icon-sm); padding: 4px; margin-block: -4px;   /* 24px hit target */
  border: none; background: transparent; color: var(--ink-subtle); cursor: pointer; }

.ph-banner {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font: var(--weight-regular) var(--text-sm)/1.45 var(--font-sans);
  background: var(--surface-sunken); color: var(--ink);
}
.ph-banner .ph-ico { margin-block-start: 1px; }
.ph-banner__title { font-weight: var(--weight-medium); }
.ph-banner--ai { background: var(--ai-bg); color: var(--ai-fg); }
.ph-banner--success { background: var(--success-bg); color: var(--success-fg); }
.ph-banner--warning { background: var(--warning-bg); color: var(--warning-fg); }
.ph-banner--alert { background: var(--alert-bg); color: var(--alert-fg); }

.ph-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--space-2); padding: var(--space-12); max-inline-size: var(--container-content); margin-inline: auto;
}
.ph-empty .ph-ico { color: var(--ink-subtle); margin-block-end: var(--space-2); }
.ph-empty__title { font: var(--weight-semibold) var(--text-xl)/1.3 var(--font-sans); color: var(--ink); }
.ph-empty__body { color: var(--ink-muted); font-size: var(--text-base); }
.ph-empty__action { margin-block-start: var(--space-4); }

.ph-skeleton {
  border-radius: var(--radius-sm); background: var(--surface-sunken);
  background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent);
  background-size: 200% 100%; background-repeat: no-repeat;
  animation: ph-shimmer 1.4s linear infinite; block-size: 12px;
}
.ph-skeleton--text { block-size: 10px; margin-block: 4px; }
.ph-skeleton--title { block-size: 16px; inline-size: 50%; }
.ph-skeleton--avatar { inline-size: 32px; block-size: 32px; border-radius: var(--radius-full); }

.ph-progress { block-size: 6px; inline-size: 100%; border-radius: var(--radius-full); background: var(--surface-sunken); overflow: hidden; }
.ph-progress__bar { block-size: 100%; background: var(--accent); border-radius: var(--radius-full); }

.ph-error-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-10); }
.ph-error-state .ph-ico { color: var(--ink-subtle); }

/* ============================================================================
   7 · DATA DISPLAY
   ========================================================================== */
.ph-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); }
.ph-card--interactive { cursor: pointer; transition: box-shadow var(--duration-fast) var(--ease-standard); }
.ph-card--interactive:hover { box-shadow: var(--shadow-sm); }
.ph-well { background: var(--surface-sunken); border-radius: var(--radius-md); padding: var(--space-3); }   /* inner grouping; never nest cards */

.ph-list { display: flex; flex-direction: column; }
.ph-list-row {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  min-block-size: var(--row-list); padding-block: var(--space-2); padding-inline: var(--space-3);
  border-block-end: 1px solid var(--border); cursor: pointer; text-decoration: none; color: inherit;
  transition: background var(--duration-fast) var(--ease-standard);
}
.ph-list-row:hover { background: var(--surface-sunken); }
.ph-list-row__main { min-inline-size: 0; flex: 1; }
.ph-list-row__name { font: var(--weight-medium) var(--text-sm)/1.3 var(--font-sans); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-list-row__sub { font-size: var(--text-xs); color: var(--ink-muted); }
.ph-list-row__meta { color: var(--ink-subtle); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.ph-list-row[aria-selected="true"] { background: var(--surface-sunken); }
.ph-list-row[aria-selected="true"]::before {
  content: ""; position: absolute; inset-inline-start: 0; inset-block: 8px;
  inline-size: 2px; border-radius: var(--radius-full); background: var(--accent); }
.ph-list--compact .ph-list-row { min-block-size: var(--row-list-compact); }

.ph-table { inline-size: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.ph-table th { text-align: start; padding: var(--space-2) var(--space-3); block-size: var(--row-table);
  font: var(--weight-medium) var(--text-xs)/1 var(--font-sans); color: var(--ink-muted);
  border-block-end: 1px solid var(--border); position: sticky; inset-block-start: 0; background: var(--surface); z-index: var(--z-sticky); }
.ph-table td { padding: var(--space-2) var(--space-3); block-size: var(--row-table);
  border-block-end: 1px solid var(--border); color: var(--ink); }
.ph-table tbody tr:hover { background: var(--surface-sunken); }
.ph-table .ph-num { text-align: end; font-variant-numeric: tabular-nums; }
.ph-table th[aria-sort] { cursor: pointer; }
.ph-table--compact th, .ph-table--compact td { block-size: var(--row-table-compact); }

.ph-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4); }
.ph-metric__label { font-size: var(--text-sm); color: var(--ink-muted); }
.ph-metric__value { font: var(--weight-semibold) var(--text-2xl)/1.1 var(--font-sans); color: var(--ink); font-variant-numeric: tabular-nums; margin-block: 2px; }
.ph-metric__context { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); color: var(--ink-muted); }
.ph-metric__context--up { color: var(--success-fg); }
.ph-metric__context--down { color: var(--alert-fg); }

/* ============================================================================
   8 · SIGNATURE SURFACES
   ========================================================================== */
/* 8.1 Relationship card — replaces the ticket detail */
.ph-rcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); max-inline-size: 420px; }
.ph-rcard__head { display: flex; align-items: center; gap: var(--space-3); }
.ph-rcard__id { min-inline-size: 0; flex: 1; }
.ph-rcard__name { font: var(--weight-semibold) var(--text-lg)/1.2 var(--font-sans); color: var(--ink); }
.ph-rcard__meta { font-size: var(--text-xs); color: var(--ink-subtle); margin-block-start: 1px; }
.ph-rcard__channels { display: inline-flex; gap: var(--space-1); color: var(--ink-subtle); }
.ph-rcard__divider { block-size: 1px; background: var(--border); margin-block: var(--space-3); }
.ph-rcard__row { display: flex; gap: var(--space-6); font-size: var(--text-sm); }
.ph-rcard__row dt { color: var(--ink-subtle); font-size: var(--text-xs); }
.ph-rcard__row dd { margin: 0; color: var(--ink); font-weight: var(--weight-medium); }
.ph-rcard__nba { background: var(--surface-sunken); border-radius: var(--radius-md); padding: var(--space-3); }
.ph-rcard__nba-label { display: inline-flex; align-items: center; gap: var(--space-1);
  font: var(--weight-medium) var(--text-xs)/1 var(--font-sans); color: var(--ai-fg); }
.ph-rcard__nba-body { display: flex; align-items: center; gap: var(--space-3); margin-block-start: var(--space-2); font-size: var(--text-sm); color: var(--ink); }
.ph-rcard__nba-body .ph-btn { margin-inline-start: auto; }

/* 8.2 Concierge chat */
.ph-chat { display: flex; flex-direction: column; gap: var(--space-4); }
.ph-msg { max-inline-size: 70%; }
.ph-msg__meta { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); color: var(--ink-subtle); margin-block-end: 4px; }
.ph-msg__bubble { padding: var(--space-3); border-radius: var(--radius-lg); font-size: var(--text-md); line-height: 1.5; }
.ph-msg--in { align-self: flex-start; }
.ph-msg--in .ph-msg__bubble { background: var(--surface); border: 1px solid var(--border); color: var(--ink);
  border-start-start-radius: var(--radius-xs); }
.ph-msg--ai { align-self: flex-start; }
.ph-msg--ai .ph-msg__meta { color: var(--ai-fg); }
.ph-msg--ai .ph-msg__bubble { background: var(--surface); border: 1px solid var(--border); color: var(--ink);
  border-start-start-radius: var(--radius-xs); }   /* neutral by default — the lavender ✦ marker carries AI; don't drown the thread */
.ph-msg--ai-emphasis .ph-msg__bubble { background: var(--ai-bg); border-color: transparent; color: var(--ai-fg); }
.ph-msg--out { align-self: flex-end; }
.ph-msg--out .ph-msg__meta { justify-content: flex-end; }
.ph-msg--out .ph-msg__bubble { background: var(--surface-sunken); color: var(--ink); border-start-end-radius: var(--radius-xs); }
.ph-msg__why { margin-inline-start: var(--space-2); font-size: var(--text-xs); color: var(--accent); cursor: pointer; }
.ph-msg__lang { font-size: var(--text-xs); color: var(--ink-subtle); margin-block-start: 4px; }
.ph-typing { display: inline-flex; gap: 3px; padding: var(--space-2) var(--space-3); }
.ph-typing span { inline-size: 5px; block-size: 5px; border-radius: var(--radius-full); background: var(--ink-subtle); animation: ph-pulse 1.2s var(--ease-standard) infinite; }
.ph-typing span:nth-child(2) { animation-delay: .2s; }
.ph-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ph-pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

/* 8.3 AI action log — accountability rendered */
.ph-actionlog { display: flex; flex-direction: column; }
.ph-action { border-block-end: 1px solid var(--border); }
.ph-action__row { display: flex; align-items: center; gap: var(--space-2); padding-block: var(--space-3); }
.ph-action__marker { color: var(--ai-fg); }
.ph-action__summary { flex: 1; min-inline-size: 0; font-size: var(--text-sm); color: var(--ink); }
.ph-action__time { font: var(--weight-regular) var(--text-xs)/1 var(--font-mono); color: var(--ink-subtle); font-variant-numeric: tabular-nums; }
.ph-disclosure { display: inline-flex; align-items: center; gap: var(--space-1); padding-block: 6px; margin-block: -6px;   /* >=24px hit target */
  border: none; background: transparent; color: var(--ink-muted); font: var(--weight-medium) var(--text-xs)/1 var(--font-sans); cursor: pointer; }
.ph-disclosure .ph-ico { transition: transform var(--duration-base) var(--ease-standard); }
.ph-disclosure[aria-expanded="true"] .ph-ico { transform: rotate(90deg); }
.ph-action__detail { padding: 0 0 var(--space-3) calc(var(--icon-sm) + var(--space-2)); font-size: var(--text-sm); color: var(--ink-muted); line-height: 1.5; }
.ph-action__lineage { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-block-start: var(--space-2); }
.ph-action__lineage .ph-tag { background: var(--surface-sunken); color: var(--ink-muted); }
.ph-action__detail-actions { display: flex; gap: var(--space-2); margin-block-start: var(--space-3); }
.ph-action__status--ok { color: var(--success-fg); }
.ph-action__status--review { color: var(--warning-fg); }
.ph-action__status--failed { color: var(--alert-fg); }

/* ============================================================================
   9 · COMBOBOX / AUTOCOMPLETE / LISTBOX
   Input + filtered listbox. The input is a .ph-field; the popover reuses the
   menu/popover elevation. Drive aria-expanded / aria-activedescendant /
   aria-selected from JS (behaviors.js) — the CSS styles whatever state is set.
   ========================================================================== */
.ph-combobox { position: relative; display: inline-flex; flex-direction: column; inline-size: 100%; }
.ph-combobox__trigger { position: relative; display: flex; align-items: center; }
.ph-combobox__trigger .ph-field { inline-size: 100%; padding-inline-end: calc(var(--space-3) * 2 + var(--icon-sm)); }
.ph-combobox__caret { position: absolute; inset-inline-end: var(--space-3); color: var(--ink-muted); pointer-events: none;
  transition: transform var(--duration-fast) var(--ease-standard); }
.ph-combobox[aria-expanded="true"] .ph-combobox__caret { transform: rotate(180deg); }

.ph-listbox {
  position: absolute; inset-block-start: calc(100% + var(--space-1)); inset-inline: 0; z-index: var(--z-dropdown);
  max-block-size: 264px; overflow-y: auto; padding: var(--space-1);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.ph-listbox[hidden] { display: none; }
.ph-option {
  display: flex; align-items: center; gap: var(--space-2);
  min-block-size: var(--control-md); padding-block: var(--space-1); padding-inline: var(--space-2);
  border-radius: var(--radius-sm); color: var(--ink); font-size: var(--text-sm); cursor: pointer;
}
.ph-option__check { margin-inline-start: auto; color: var(--accent); visibility: hidden; }
.ph-option[aria-selected="true"] .ph-option__check { visibility: visible; }
.ph-option.is-active, .ph-option:hover { background: var(--surface-sunken); }   /* .is-active = keyboard highlight (aria-activedescendant) */
.ph-option[aria-disabled="true"] { color: var(--ink-subtle); cursor: not-allowed; }
.ph-option mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 2px; }   /* matched substring */
.ph-listbox__empty { padding: var(--space-3) var(--space-2); color: var(--ink-subtle); font-size: var(--text-sm); text-align: center; }
.ph-combobox__tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-block-end: var(--space-1); }   /* multi-select selected chips */

/* ============================================================================
   10 · DATE PICKER / CALENDAR
   A calendar grid in a popover, opened from a .ph-field with a trailing icon.
   ========================================================================== */
.ph-datefield { position: relative; }
.ph-datefield .ph-field { padding-inline-end: calc(var(--space-3) * 2 + var(--icon-sm)); }
.ph-datefield__icon { position: absolute; inset-inline-end: var(--space-3); inset-block-start: 50%; transform: translateY(-50%);
  color: var(--ink-muted); pointer-events: none; }

.ph-calendar {
  inline-size: max-content; padding: var(--space-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); z-index: var(--z-popover);
}
.ph-calendar__head { display: flex; align-items: center; gap: var(--space-2); margin-block-end: var(--space-2); }
.ph-calendar__title { flex: 1; text-align: center; font: var(--weight-semibold) var(--text-sm)/1 var(--font-sans); color: var(--ink); }
.ph-calendar__grid { display: grid; grid-template-columns: repeat(7, 36px); gap: 2px; }
.ph-calendar__dow { block-size: 28px; display: grid; place-content: center;
  font: var(--weight-medium) var(--text-2xs)/1 var(--font-sans); color: var(--ink-subtle); }
.ph-day {
  inline-size: 36px; block-size: 36px; display: grid; place-content: center; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent;
  color: var(--ink); font: var(--weight-regular) var(--text-sm)/1 var(--font-sans);
  font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background var(--duration-fast) var(--ease-standard);
}
.ph-day:hover { background: var(--surface-sunken); }
.ph-day--outside { color: var(--ink-subtle); }
.ph-day--today { border-color: var(--field-border); font-weight: var(--weight-semibold); }
.ph-day[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.ph-day--in-range { background: var(--selection-bg); border-radius: 0; }   /* range middle */
.ph-day--range-start { border-start-end-radius: 0; border-end-end-radius: 0; }
.ph-day--range-end { border-start-start-radius: 0; border-end-start-radius: 0; }
.ph-day:disabled, .ph-day[aria-disabled="true"] { color: var(--disabled-fg); cursor: not-allowed; background: transparent; }

/* ============================================================================
   11 · PAGINATION
   ========================================================================== */
.ph-pagination { display: flex; align-items: center; gap: var(--space-1); }
.ph-pagination__info { color: var(--ink-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; margin-inline-end: var(--space-2); }
.ph-page {
  display: inline-grid; place-content: center; min-inline-size: var(--control-md); block-size: var(--control-md); padding-inline: var(--space-2);
  border: 1px solid transparent; border-radius: var(--radius-md); background: transparent;
  color: var(--ink-muted); font: var(--weight-medium) var(--text-sm)/1 var(--font-sans);
  font-variant-numeric: tabular-nums; cursor: pointer; text-decoration: none;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}
.ph-page:hover { background: var(--surface-sunken); color: var(--ink); }
.ph-page[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.ph-page:disabled, .ph-page[aria-disabled="true"] { color: var(--disabled-fg); cursor: not-allowed; background: transparent; }
.ph-pagination__gap { color: var(--ink-subtle); padding-inline: var(--space-1); user-select: none; }   /* the … ellipsis */
.ph-page .ph-ico { transform: none; }
[dir="rtl"] .ph-page__prev .ph-ico, [dir="rtl"] .ph-page__next .ph-ico { transform: scaleX(-1); }   /* directional chevrons mirror */

/* ============================================================================
   12 · SLIDER / RANGE
   Styled native <input type="range"> — keyboard + screen-reader for free.
   The 2.5.7 no-drag alternative: pair with +/- buttons or a number field.
   ========================================================================== */
.ph-range { inline-size: 100%; block-size: var(--control-md); background: transparent; cursor: pointer; appearance: none; -webkit-appearance: none; }
.ph-range::-webkit-slider-runnable-track { block-size: 6px; border-radius: var(--radius-full); background: var(--surface-sunken); }
.ph-range::-moz-range-track { block-size: 6px; border-radius: var(--radius-full); background: var(--surface-sunken); }
.ph-range::-moz-range-progress { block-size: 6px; border-radius: var(--radius-full); background: var(--accent); }   /* filled portion (Firefox) */
.ph-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-block-start: -5px;   /* centre the 16px thumb on the 6px track */
  inline-size: 16px; block-size: 16px; border-radius: var(--radius-full);
  background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}
.ph-range::-moz-range-thumb {
  inline-size: 16px; block-size: 16px; border-radius: var(--radius-full);
  background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}
.ph-range:focus-visible { outline: none; }
.ph-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ph-range:focus-visible::-moz-range-thumb { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ph-range:disabled { cursor: not-allowed; }
.ph-range:disabled::-webkit-slider-thumb { background: var(--disabled-fg); }
.ph-range:disabled::-moz-range-thumb { background: var(--disabled-fg); }
.ph-slider { display: flex; align-items: center; gap: var(--space-3); }
.ph-slider__value { min-inline-size: 3ch; text-align: end; font-variant-numeric: tabular-nums; color: var(--ink); font-size: var(--text-sm); }

/* ============================================================================
   13 · CHARTS / DATA-VIZ
   Lightweight, token-driven primitives for the outcome dashboard. Bars are pure
   CSS (set --val: 0–100 per bar); lines/areas are SVG you supply, themed by the
   --viz-* tokens. Always pair series with a label or pattern (Color-Plus-One) —
   colour is never the only signal. For complex charts, feed --viz-* to a lib.
   ========================================================================== */
.ph-chart { display: flex; flex-direction: column; gap: var(--space-3); color: var(--ink); }
.ph-chart__plot { position: relative; }

/* grid + axes — faint, never competing with the data */
.ph-chart__gridlines { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.ph-chart__gridlines span { display: block; border-block-start: 1px solid var(--border); block-size: 0; }
.ph-axis-label { font: var(--weight-regular) var(--text-2xs)/1 var(--font-sans); color: var(--ink-subtle); font-variant-numeric: tabular-nums; }

/* bar chart — a flex row of bars; height comes from inline --val (0–100) */
.ph-bars { display: flex; align-items: flex-end; gap: var(--space-2); block-size: 180px; }
.ph-bars--grouped .ph-bar-group { display: flex; align-items: flex-end; gap: 2px; flex: 1; block-size: 100%; }
.ph-bar { flex: 1; min-inline-size: 8px; block-size: calc(var(--val, 0) * 1%); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--viz-1); transition: block-size var(--duration-slow) var(--ease-entrance); }
.ph-bar--2 { background: var(--viz-2); } .ph-bar--3 { background: var(--viz-3); }
.ph-bar--4 { background: var(--viz-4); } .ph-bar--5 { background: var(--viz-5); }
.ph-bar--6 { background: var(--viz-6); } .ph-bar--7 { background: var(--viz-7); }
.ph-bar--positive { background: var(--viz-positive); } .ph-bar--negative { background: var(--viz-negative); }
.ph-bar--muted { background: var(--surface-sunken); }
.ph-bars__labels { display: flex; gap: var(--space-2); margin-block-start: var(--space-1); }
.ph-bars__labels > * { flex: 1; text-align: center; }

/* SVG line/area — you supply <svg viewBox><path>; these class the strokes/fills */
.ph-linechart { inline-size: 100%; block-size: auto; overflow: visible; }
.ph-linechart .ph-line { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ph-linechart .ph-line--2 { stroke: var(--viz-2); } .ph-linechart .ph-line--3 { stroke: var(--viz-3); }
.ph-linechart .ph-area { stroke: none; fill: color-mix(in srgb, var(--viz-1) 14%, transparent); }
.ph-linechart .ph-grid line, .ph-linechart .ph-grid path { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ph-linechart .ph-dot { fill: var(--surface); stroke: var(--viz-1); stroke-width: 2; }

/* sparkline — inline trend, no axes */
.ph-sparkline { inline-size: 96px; block-size: 28px; overflow: visible; vertical-align: middle; }
.ph-sparkline path { fill: none; stroke: var(--viz-1); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.ph-sparkline--up path { stroke: var(--viz-positive); } .ph-sparkline--down path { stroke: var(--viz-negative); }

/* legend — the label half of Color-Plus-One */
.ph-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.ph-legend__item { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--ink-muted); }
.ph-legend__swatch { inline-size: 10px; block-size: 10px; border-radius: 3px; background: var(--viz-1); flex: none; }
.ph-legend__swatch--2 { background: var(--viz-2); } .ph-legend__swatch--3 { background: var(--viz-3); }
.ph-legend__swatch--4 { background: var(--viz-4); } .ph-legend__swatch--5 { background: var(--viz-5); }
.ph-legend__swatch--6 { background: var(--viz-6); } .ph-legend__swatch--7 { background: var(--viz-7); }

/* ============================================================================
   Windows High Contrast / forced-colors — keep shape, state & focus when the
   custom fills are dropped by the OS. (WCAG 1.4.11 / robustness)
   ========================================================================== */
@media (forced-colors: active) {
  /* focus uses a system colour so it survives the override */
  :where(.ph-btn, .ph-icon-btn, .ph-nav-item, .ph-menu-item, .ph-tab, .ph-list-row, .ph-link,
    .ph-switch, .ph-checkbox, .ph-radio, .ph-cmdk-row, .ph-disclosure, .ph-breadcrumb a,
    .ph-tag__remove, .ph-toast__close):focus-visible { outline-color: Highlight; }
  /* tinted surfaces lose their fill — a real border keeps the edge */
  .ph-btn, .ph-field, .ph-badge, .ph-pill, .ph-tag, .ph-banner, .ph-toast, .ph-card, .ph-rcard,
  .ph-menu, .ph-popover, .ph-dialog, .ph-cmdk, .ph-msg__bubble, .ph-switch,
  .ph-listbox, .ph-calendar, .ph-bar, .ph-legend__swatch { border: 1px solid; }
  /* selected day / current page / active option lose their fill — outline keeps the state */
  .ph-day[aria-selected="true"], .ph-page[aria-current="page"],
  .ph-option.is-active, .ph-option[aria-selected="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .ph-error-summary { border: 1px solid; }
  /* ::before indicator bars are backgrounds (invisible in WHCM) — use a logical border instead */
  .ph-nav-item[aria-current="page"], .ph-list-row[aria-selected="true"],
  .ph-cmdk-row[aria-selected="true"] { border-inline-start: 2px solid Highlight; }
  .ph-nav-item[aria-current="page"]::before, .ph-list-row[aria-selected="true"]::before,
  .ph-cmdk-row[aria-selected="true"]::before { display: none; }
  /* checked/on state must not rely on fill alone */
  .ph-checkbox:checked, .ph-radio:checked, .ph-switch:checked { outline: 2px solid Highlight; outline-offset: 1px; }
}

/* ============================================================================
   Accessibility utilities — screen-reader text & the skip link
   ========================================================================== */
/* Visually hidden but available to assistive tech (announcements, icon-button names,
   "Loading"/"Saved" status text). Never display:none — that hides it from SRs too. */
.ph-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
/* Reveal when focused — for skip links and "show on focus" helpers. */
.ph-sr-only--focusable:focus, .ph-sr-only--focusable:focus-visible {
  position: fixed; width: auto; height: auto; margin: 0; overflow: visible;
  clip: auto; clip-path: none; white-space: normal;
}

/* Skip link — the first tab stop on every surface; hidden until focused. */
.ph-skip-link {
  position: fixed; inset-block-start: var(--space-2); inset-inline-start: var(--space-2);
  z-index: var(--z-tooltip); transform: translateY(-150%); opacity: 0; pointer-events: none;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-md);
  font: var(--weight-medium) var(--text-sm)/1 var(--font-sans); text-decoration: none;
  transition: transform var(--duration-fast) var(--ease-entrance), opacity var(--duration-fast);
}
.ph-skip-link:focus-visible {
  transform: translateY(0); opacity: 1; pointer-events: auto;
  outline: 2px solid var(--focus-ring); outline-offset: 2px;
}

/* prefers-contrast: more — token values strengthen in tokens.css; here the focus
   line itself widens. Lives in components.css because this layer owns focus. */
@media (prefers-contrast: more) {
  :where(.ph-btn, .ph-icon-btn, .ph-nav-item, .ph-menu-item, .ph-tab, .ph-list-row,
    .ph-link, .ph-tag__remove, .ph-switch, .ph-checkbox, .ph-radio, .ph-cmdk-row,
    .ph-disclosure, .ph-breadcrumb a, .ph-toast__close):focus-visible { outline-width: 3px; }
  .ph-field:focus-visible { box-shadow: 0 0 0 3px var(--field-focus); }
}

/* ============================================================================
   Reduced motion — the global kill-switch in tokens.css stops all animation.
   The loading spinner is ESSENTIAL motion (WCAG 2.3.3): a frozen ring reads as
   "stuck", not "working", so it keeps rotating (just a touch slower). The
   shimmer/typing/decorative animations stay disabled by the global rule.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .ph-spinner { animation: ph-spin 1.4s linear infinite !important; }
}
