/* HUD over the 3D plant (artboard 08). Tokens from design/system.md via css/tokens.css,
   each with the system.md value as fallback. State colours resolve to the on-dark values that
   css/tokens.css sets inside .scene-host (fallbacks are the same on-dark values from system.md). */
.pah-hud {
  --h-glass: var(--glass, rgba(18, 18, 22, .82));
  --h-line: var(--glass-line, rgba(255, 255, 255, .12));
  --h-radius: var(--radius, 12px);
  --h-accent: var(--accent, #1f3fa8);
  --h-accent-hi: var(--accent-hi, #3d63e0);
  --h-font: var(--font, "DM Sans", Poppins, system-ui, -apple-system, "Segoe UI", sans-serif);
  --h-mono: var(--mono, ui-monospace, "SFMono-Regular", Menlo, monospace);
  --h-run: var(--run, #2fbf7a);
  --h-stop: var(--stop, #8a9aa6);
  --h-warn: var(--warn, #f2c230);
  --h-alarm: var(--alarm, #ff5a52);
  --h-hand: var(--hand, #a77bf0);
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  font: 14px/1.35 var(--h-font); color: #fff;
}
.pah-hud *, .pah-hud *::before, .pah-hud *::after { box-sizing: border-box; }
.pah-hud button { font: inherit; color: inherit; cursor: pointer; }
.pah-hud button:focus-visible, .pah-hud input:focus-visible { outline: 3px solid var(--h-accent-hi); outline-offset: 2px; }
.pah-hud [hidden] { display: none !important; }
.pah-hud-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* state colours, shared by dots and badges */
.pah-hud [data-state='run']   { --st: var(--h-run); }
.pah-hud [data-state='idle']  { --st: var(--h-stop); }
.pah-hud [data-state='warn']  { --st: var(--h-warn); }
.pah-hud [data-state='hand']  { --st: var(--h-hand); }
.pah-hud [data-state='alarm'],
.pah-hud [data-state='fault'] { --st: var(--h-alarm); }

/* glass panels */
.pah-hud-rail, .pah-hud-fly, .pah-hud-card, .pah-hud-cams {
  pointer-events: auto; background: var(--h-glass); border: 1px solid var(--h-line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* 1. rail */
.pah-hud-rail {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 56px;
  padding: 8px 0; display: flex; flex-direction: column; gap: 4px; border-radius: var(--h-radius);
}
.pah-hud-rail__btn {
  position: relative; height: 46px; background: none; border: 0; display: grid; place-items: center;
  transition: background .15s;
}
.pah-hud-rail__btn:hover { background: rgba(255, 255, 255, .07); }
.pah-hud-rail__btn[aria-expanded='true'] { background: rgba(31, 63, 168, .55); }
.pah-hud-rail__ico { display: grid; place-items: center; }
.pah-hud-rail__n {
  position: absolute; right: 6px; top: 3px; min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center;
  background: var(--h-alarm); color: #1b0000; font: 700 10px var(--h-font); border-radius: 99px;
}
.pah-hud-rail__d { position: absolute; right: 10px; bottom: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--st, var(--h-stop)); box-shadow: 0 0 0 2px rgba(18, 18, 22, .9); }

/* 2. flyout */
.pah-hud-fly {
  position: absolute; left: 74px; width: 320px; padding: 10px; border-radius: var(--h-radius);
}
.pah-hud-fly h3 { margin: 2px 4px 8px; font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, .85); }
.pah-hud-row {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; width: 100%;
  background: none; border: 0; padding: 8px 6px; border-radius: 8px; text-align: left; font-size: 13px;
}
.pah-hud-row:hover { background: rgba(255, 255, 255, .07); }
.pah-hud-row[aria-current] { background: rgba(31, 63, 168, .5); }
.pah-hud-row__name { white-space: nowrap; }
.pah-hud-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--st, var(--h-stop)); }
.pah-hud-row small { white-space: nowrap; font: 12px var(--h-mono); color: rgba(255, 255, 255, .78); }

/* 3. unit card */
.pah-hud-card {
  position: absolute; right: 12px; top: 12px; width: 300px; max-height: calc(100% - 24px); overflow-y: auto;
  padding: 12px 14px; border-top: 3px solid var(--h-accent-hi); border-radius: 10px;
}
.pah-hud-card__head { display: flex; justify-content: space-between; align-items: center; }
.pah-hud-card__title { margin: 0; font-size: 19px; }
.pah-hud-card__close { background: none; border: 0; padding: 4px; border-radius: 6px; display: grid; place-items: center; }
.pah-hud-card__close svg { width: 18px; height: 18px; }
.pah-hud-card__model { font-size: 12px; color: rgba(255, 255, 255, .72); }
.pah-hud-card__status { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 8px 0; }
.pah-hud-badge {
  display: inline-block; padding: 3px 8px; border-radius: 6px; font-weight: 700; font-size: 13px;
  color: var(--st, #fff); background: color-mix(in srgb, var(--st, var(--h-stop)) 22%, transparent);
}
.pah-hud-card__key { font: 800 16px var(--h-mono); }
.pah-hud-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; font-size: 12px; color: rgba(255, 255, 255, .74); }
.pah-hud-grid dt { margin: 0; }
.pah-hud-grid dd { margin: 0; color: #fff; }
.pah-hud-grid b { font: 700 14px var(--h-mono); }
.pah-hud-unit { font-size: 11px; color: rgba(255, 255, 255, .7); }
.pah-hud-load { display: flex; justify-content: space-between; margin: 10px 0 3px; font-size: 12px; }
.pah-hud-bar { height: 5px; background: rgba(255, 255, 255, .15); border-radius: 3px; }
.pah-hud-bar i { display: block; height: 100%; background: var(--h-accent-hi); border-radius: 3px; transition: width .4s; }
.pah-hud-card__modes { margin-top: 12px; font-size: 11px; letter-spacing: 1px; font-weight: 700; color: rgba(255, 255, 255, .75); }
.pah-hud-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.pah-hud-seg button {
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .04); border-radius: var(--radius-sm, 6px);
  padding: 7px 0; font-weight: 800; font-size: 11px;
}
.pah-hud-seg button:hover { background: rgba(255, 255, 255, .1); }
.pah-hud-seg button.is-hand { color: #d9c6ff; }
.pah-hud-seg button[aria-pressed='true'] { background: var(--h-accent); border-color: var(--h-accent-hi); color: #fff; }
.pah-hud-seg button.is-hand[aria-pressed='true'] { background: var(--h-hand); border-color: var(--h-hand); color: #120a26; }
.pah-hud-pop {
  margin-top: 8px; padding: 10px; border: 1px solid var(--h-line); border-radius: 8px; background: rgba(255, 255, 255, .06); font-size: 12px;
}
.pah-hud-pop p { margin: 0 0 6px; }
.pah-hud-pop__change { font-weight: 700; font-size: 13px; }
.pah-hud-pop__warn { color: var(--h-warn); }
.pah-hud-pop label { display: block; margin-bottom: 3px; color: rgba(255, 255, 255, .75); }
.pah-hud-pop__note {
  width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(0, 0, 0, .3); color: #fff; font: 13px var(--h-font);
}
.pah-hud-pop__acts { display: flex; gap: 6px; margin-top: 8px; }
.pah-hud-reject { margin: 8px 0 0; font-weight: 700; font-size: 12px; color: var(--h-alarm); }
.pah-hud-last { margin: 8px 0 0; font-size: 12px; color: rgba(255, 255, 255, .78); }
.pah-hud-erp { margin-top: 12px; border-top: 1px solid var(--h-line); padding-top: 10px; font-size: 13px; }
.pah-hud-erp small { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 800; letter-spacing: 1px; color: #8fa9ff; }
.pah-hud-acts, .pah-hud-pop__acts { display: flex; gap: 8px; }
.pah-hud-acts { margin-top: 12px; }
.pah-hud-acts button, .pah-hud-pop__acts button {
  flex: 1; border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .06);
  border-radius: var(--radius-sm, 6px); padding: 7px; font-weight: 700;
}
.pah-hud-acts button:hover, .pah-hud-pop__acts button:hover { background: rgba(255, 255, 255, .14); }
.pah-hud .is-primary { background: var(--h-accent); border-color: var(--h-accent); }
.pah-hud .is-primary:hover { background: var(--h-accent-hi); }

/* 4. camera bar */
.pah-hud-cams {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 18px; display: flex; gap: 6px; padding: 5px; border-radius: var(--pill, 999px);
}
.pah-hud-cams button { border: 0; background: none; border-radius: 99px; padding: 6px 12px; font-weight: 700; font-size: 12px; }
.pah-hud-cams button:hover { background: rgba(255, 255, 255, .1); }
.pah-hud-cams button[aria-pressed='true'] { background: var(--h-accent); }

@media (prefers-reduced-motion: reduce) {
  .pah-hud *, .pah-hud *::before, .pah-hud *::after { transition: none !important; animation: none !important; }
}
