/* System states — Sign-in failed, Error, Confirm dialog, BrandBarLayout.
   Depends on the --ph-* tokens already declared in ph-components.css. No new colours.
   Adapted from docs/UI/system-states-handoff-package/css/ph-system-states.css (2026-08-01) —
   unchanged from the source handoff; kept byte-identical except this header comment. */

/* ── tone map ─────────────────────────────────────────────── */
.is-primary { --tone: var(--ph-primary-dark); --tone-bg: rgba(0,178,226,.08); --tone-br: rgba(0,178,226,.30); --tone-solid: var(--ph-primary); --tone-shadow: 0 2px 8px rgba(0,178,226,.32); }
.is-danger  { --tone: var(--ph-red);          --tone-bg: var(--ph-red-bg);    --tone-br: var(--ph-red-border);  --tone-solid: var(--ph-red);     --tone-shadow: 0 2px 8px rgba(180,30,21,.28); }
.is-warning { --tone: var(--ph-amber);        --tone-bg: var(--ph-amber-bg);  --tone-br: rgba(180,101,0,.28);   --tone-solid: var(--ph-amber);   --tone-shadow: 0 2px 8px rgba(180,101,0,.26); }
.is-slate   { --tone: var(--ph-slate);        --tone-bg: rgba(85,96,110,.09); --tone-br: rgba(85,96,110,.26);   --tone-solid: var(--ph-slate);   --tone-shadow: 0 2px 8px rgba(85,96,110,.26); }

/* ── shared page shell ────────────────────────────────────── */
.ph-state-wrap { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 40px; }

.ph-state-card {
  width: 100%; max-width: 620px; overflow: hidden;
  background: var(--ph-surface); border: 1px solid var(--ph-divider);
  border-radius: 14px; box-shadow: 0 6px 26px rgba(0,0,0,.07);
}
/* ── error / sign-in-failed screen — centred, cause-free ──── */
/* Shared by /error and /signin-failed. */
.ph-oops {
  width: 100%; max-width: 620px; text-align: center;
  display: flex; flex-direction: column; align-items: center;
  padding: 44px 44px 40px;
  background: var(--ph-surface); border: 1px solid var(--ph-divider);
  border-radius: 14px; box-shadow: 0 6px 26px rgba(0,0,0,.07);
}
.ph-oops__glyph {
  width: 84px; height: 84px; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ph-surface-2); border: 1px solid var(--ph-divider);
  color: var(--ph-slate);                  /* NOT red — temporary, and not the user's fault */
}
.ph-oops__glyph .mud-icon-root { font-size: 42px; }
.ph-oops__title { margin: 26px 0 0; font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; color: var(--ph-text); }
.ph-oops__body  { margin: 14px 0 0; font-size: 15px; line-height: 1.65; color: var(--ph-text-2); max-width: 48ch; text-wrap: pretty; }
.ph-oops__actions { margin-top: 30px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.ph-oops__support {
  margin-top: 34px; padding-top: 22px; width: 100%; max-width: 460px;
  border-top: 1px solid var(--ph-divider);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.ph-oops__supporttext { font-size: 12.5px; color: var(--ph-text-2); }
.ph-refchip {
  display: inline-flex; align-items: center; gap: 9px;
  height: 34px; padding: 0 12px 0 14px; border-radius: 17px;
  border: 1px solid var(--ph-divider); background: var(--ph-surface-2);
  color: var(--ph-text-2); font-size: 12.5px; cursor: pointer;
}
.ph-refchip:hover { background: var(--ph-hover); }
.ph-refchip .mud-icon-root { color: var(--ph-text-3); }

.ph-state-head { padding: 34px 38px 28px; display: flex; gap: 22px; align-items: flex-start; }

.ph-state-icon {
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tone-bg); border: 1px solid var(--tone-br); color: var(--tone);
}
.ph-state-icon .mud-icon-root { font-size: 30px; }
.ph-state-icon--lg { width: 62px; height: 62px; border-radius: 16px; }

.ph-state-kicker { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--tone); }
.ph-state-title  { margin: 8px 0 0; font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; color: var(--ph-text); }
.ph-state-title--lg { font-size: 26px; margin-top: 20px; }
.ph-state-body   { margin: 12px 0 0; font-size: 14.5px; line-height: 1.62; color: var(--ph-text-2); text-wrap: pretty; }
.ph-state-body--centered { max-width: 46ch; }

.ph-state-rule { margin: 0 38px; border-top: 1px solid var(--ph-divider); }

/* ── detail grid ──────────────────────────────────────────── */
.ph-state-grid {
  margin: 0; padding: 20px 38px 22px; font-size: 13px;
  display: grid; grid-template-columns: 152px 1fr; gap: 11px 18px;
}
.ph-state-grid dt { color: var(--ph-text-3); }
.ph-state-grid dd { margin: 0; color: var(--ph-text); }
.ph-state-identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.ph-state-identity .ph-mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-state-name { font-weight: 600; }
.ph-avatar {
  width: 24px; height: 24px; flex: 0 0 auto; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 9.5px; font-weight: 700;
}

/* ── developer exception dump — Development builds ONLY ───── */
.ph-console {
  margin: 10px 0 0; padding: 14px 16px; overflow: auto;
  border-radius: 9px; border: 1px solid var(--ph-divider);
  background: #1d2126;                     /* intentionally dark in BOTH themes */
  font-family: "Roboto Mono", monospace; font-size: 12px; line-height: 1.75;
  color: rgba(255,255,255,.78); white-space: pre;
}

/* ── footers & buttons ────────────────────────────────────── */
.ph-state-foot {
  padding: 18px 38px 24px; border-top: 1px solid var(--ph-divider);
  background: var(--ph-surface-2);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.ph-state-support { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ph-text-3); }
.ph-state-corr { margin-left: auto; font-size: 11.5px; color: var(--ph-text-3); }

.ph-btn {
  height: 44px; padding: 0 20px; display: inline-flex; align-items: center; gap: 9px;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; text-transform: none;
  white-space: nowrap;
}
.ph-btn--sm { height: 36px; padding: 0 16px; font-size: 13px; }
.ph-btn--lg { height: 46px; padding: 0 24px; font-size: 14.5px; }
.ph-btn--solid { border: none; color: #fff; background: var(--tone-solid); box-shadow: var(--tone-shadow, 0 2px 8px rgba(0,0,0,.14)); }
.ph-btn--solid:hover:not(:disabled) { filter: brightness(.92); }
.ph-btn--solid:disabled { background: #9aa4b0; opacity: .75; cursor: not-allowed; box-shadow: none; }
.ph-btn--ghost { border: 1px solid var(--ph-divider); background: var(--ph-surface); color: var(--ph-text); }
.ph-btn--ghost:hover:not(:disabled) { background: var(--ph-hover); }

.ph-linkbtn {
  display: inline-flex; align-items: center; gap: 6px; padding: 0;
  border: none; background: transparent; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: var(--ph-text-2);
}
.ph-linkbtn--pad { height: 44px; padding: 0 14px; border-radius: 8px; font-size: 13.5px; }
.ph-linkbtn--pad:hover { background: var(--ph-hover); }

.ph-dim  { color: var(--ph-text-2); }
.ph-strong { color: var(--ph-text); font-weight: 600; }

/* ── confirm dialog ───────────────────────────────────────── */
.mud-dialog:has(.ph-confirm) {
  max-width: 468px; width: 100%; border-radius: 14px; overflow: hidden;
  background: var(--ph-surface); box-shadow: 0 24px 64px rgba(0,0,0,.32);
  animation: ph-dlg-in 150ms cubic-bezier(.2,.8,.3,1);
}
.mud-overlay-dialog { background: rgba(15,20,26,.48); animation: ph-scrim-in 120ms ease-out; }

@keyframes ph-dlg-in   { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes ph-scrim-in { from { opacity: 0; } to { opacity: 1; } }

.ph-confirm__head { padding: 26px 26px 20px; display: flex; gap: 16px; align-items: flex-start; }
.ph-confirm__icon {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tone-bg); border: 1px solid var(--tone-br); color: var(--tone);
}
.ph-confirm__icon .mud-icon-root { font-size: 24px; }
.ph-confirm__copy  { min-width: 0; flex: 1 1 auto; }
.ph-confirm__title { margin: 0; font-size: 18.5px; font-weight: 700; letter-spacing: -.01em; line-height: 1.28; color: var(--ph-text); }
.ph-confirm__body  { margin: 9px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--ph-text-2); text-wrap: pretty; }

.ph-confirm__note {
  margin-top: 14px; display: flex; gap: 9px; align-items: flex-start;
  padding: 11px 13px; border-radius: 8px;
  background: var(--ph-surface-2); border: 1px solid var(--ph-divider);
  font-size: 12.5px; line-height: 1.55; color: var(--ph-text-2);
}
.ph-confirm__note .mud-icon-root { color: var(--ph-text-3); }

.ph-confirm__typed { margin-top: 15px; }
.ph-confirm__typed label { display: block; font-size: 12px; font-weight: 600; color: var(--ph-text-2); }
.ph-confirm__typed code  { font-family: "Roboto Mono", monospace; font-weight: 700; color: var(--ph-text); }
.ph-confirm__input {
  margin-top: 7px; width: 100%; height: 40px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--ph-divider); background: var(--ph-surface-2);
  font-family: "Roboto Mono", monospace; font-size: 13.5px; color: var(--ph-text); outline: none;
}
.ph-confirm__input:focus { border-color: var(--ph-primary); background: var(--ph-surface); }

.ph-confirm__foot {
  padding: 16px 26px 20px; border-top: 1px solid var(--ph-divider); background: var(--ph-surface-2);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}
.ph-confirm__foot .ph-btn { height: 40px; padding: 0 18px; font-size: 13.5px; }
.ph-confirm__foot .ph-btn--solid { padding: 0 20px; }
.ph-confirm__spinner { width: 16px; height: 16px; }

/* ── responsive ───────────────────────────────────────────── */
@media (max-width: 720px) {
  .ph-state-wrap { padding: 20px; }
  .ph-state-head { padding: 26px 22px 22px; flex-direction: column; gap: 16px; }
  .ph-state-rule, .ph-state-grid, .ph-state-details, .ph-state-foot { padding-left: 22px; padding-right: 22px; }
  .ph-state-rule { margin: 0 22px; }
  .ph-state-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .ph-state-grid dt { margin-top: 10px; }
  .ph-state-title { font-size: 21px; }
  .ph-oops { padding: 30px 22px 26px; }
  .ph-oops__title { font-size: 24px; }
  .ph-oops__actions { flex-direction: column; align-self: stretch; }
  .ph-oops__actions .ph-btn { width: 100%; justify-content: center; }
  .ph-state-foot { flex-direction: column; align-items: stretch; }
  .ph-state-support, .ph-state-corr { margin-left: 0; }
  .ph-confirm__foot { flex-direction: column-reverse; }
  .ph-confirm__foot .ph-btn { width: 100%; justify-content: center; }
}

/* ── BrandBarLayout — /signin-failed, /error ──────────────── */
.ph-brandshell { min-height: 100vh; display: flex; flex-direction: column; background: var(--ph-bg); }
.ph-brandbar {
  height: 64px; flex: 0 0 auto; display: flex; align-items: center; padding: 0 22px;
  background: linear-gradient(180deg, var(--ph-primary) 0%, var(--ph-primary-dark) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.15) inset;
}
.ph-brandbar img { height: 38px; width: auto; filter: brightness(0) invert(1) drop-shadow(0 1px 1px rgba(0,0,0,.20)); }
.ph-brandbar__app {
  margin-left: 16px; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.28);
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,.92);
}
