/* Customer Headquarters map (contracts/hq/spatial_v1.md). Reuses the tokens of styles.css. */
:root {
  --st-available: #3f6f53; --st-assigned: #4f5fc4; --st-working: #187a4f; --st-collab: #0f7f86; --st-review: #2f5bd3;
  --st-waiting: #9a6514; --st-blocked: #c2410c; --st-approval: #9d1f9b; --st-attention: #b91c1c; --st-stale: #6b6760;
  --st-offline: #7b766e; --st-onboarding: #0e7490; --demo: #b45309; --demo-bg: #fff7e6;
  --hqs-room: #fdfcfa; --hqs-partition: #e8e3da; --hqs-edge: rgb(0 0 0 / 14%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --st-available: #7fc29b; --st-assigned: #9aa5ff; --st-working: #43c58a; --st-collab: #3cc4cc; --st-review: #7c9cff;
    --st-waiting: #e0a645; --st-blocked: #ff8a57; --st-approval: #ef8af2; --st-attention: #ff6b6b; --st-stale: #aaa59d;
    --st-offline: #8c8a86; --st-onboarding: #4cc3dc; --demo: #f0b35a; --demo-bg: #2a2214; --hqs-room: #1a1a1e; --hqs-partition: #2c2c33; --hqs-edge: rgb(255 255 255 / 22%);
  }
}
:root[data-theme="dark"] {
  --st-available: #7fc29b; --st-assigned: #9aa5ff; --st-working: #43c58a; --st-collab: #3cc4cc; --st-review: #7c9cff;
  --st-waiting: #e0a645; --st-blocked: #ff8a57; --st-approval: #ef8af2; --st-attention: #ff6b6b; --st-stale: #aaa59d;
  --st-offline: #8c8a86; --st-onboarding: #4cc3dc; --demo: #f0b35a; --demo-bg: #2a2214; --hqs-room: #1a1a1e; --hqs-partition: #2c2c33; --hqs-edge: rgb(255 255 255 / 22%);
}
.st-AVAILABLE { --st: var(--st-available); } .st-ASSIGNED { --st: var(--st-assigned); } .st-WORKING { --st: var(--st-working); }
.st-COLLABORATING { --st: var(--st-collab); } .st-REVIEWING { --st: var(--st-review); } .st-WAITING { --st: var(--st-waiting); }
.st-BLOCKED { --st: var(--st-blocked); } .st-NEEDS_APPROVAL { --st: var(--st-approval); } .st-ATTENTION { --st: var(--st-attention); }
.st-STALE { --st: var(--st-stale); } .st-OFFLINE { --st: var(--st-offline); } .st-ONBOARDING { --st: var(--st-onboarding); }

.layout.layout-hqs { grid-template-columns: minmax(0, 1fr); }
.layout.layout-hqs > .panel { display: none; }

.hqs-head { display: flex; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 6px; }
.hqs-head h2 { font-size: 20px; letter-spacing: -.01em; }
.hqs-head h2:focus-visible, .hqs-panel-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.hqs-titles p { margin: 2px 0 0; }
.hqs-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.hqs-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.hqs-seg button { border: 0; border-radius: 0; padding: 5px 11px; }
.hqs-seg button + button { border-left: 1px solid var(--line); }
.hqs-seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); font-weight: 600; }
.hqs-intro { margin: 4px 0 2px; max-width: 80ch; }
.hqs-statusbar { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin: 2px 0 10px; min-height: 1.6em; }
.hqs-status { color: var(--text); }
.hqs-warn { color: var(--st-blocked); }
.hqs-sub { margin: 8px 0 6px; font-size: 12px; font-weight: 600; color: var(--text); }
.hqs-next { margin-top: 2px; }
.hqs-ref { font-size: 11px; }

/* TEST/DEMO labelling stays visible on every demo surface. */
.hqs-banner { margin: 8px 0; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--demo); color: var(--text);
  background: repeating-linear-gradient(135deg, var(--demo-bg) 0 14px, color-mix(in srgb, var(--demo-bg) 70%, var(--demo)) 14px 16px); }
.hqs.is-demo .hqs-stage, .hqs.is-demo .hqs-panel { box-shadow: inset 0 3px 0 var(--demo); }
.hqs-tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 1px 6px; border-radius: 5px;
  color: var(--demo); border: 1px solid var(--demo); background: var(--demo-bg); vertical-align: middle; margin-left: 4px; }

.hqs-demo { border: 1px dashed var(--demo); border-radius: 10px; padding: 10px 12px; margin: 8px 0 12px; background: var(--surface); display: grid; gap: 8px; }
.hqs-demo-row { display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap; }
.hqs-demo-next { font-weight: 600; }
.hqs-inline { display: inline; margin: 0; font-size: 12px; }
.hqs-select { width: auto; padding: 3px 6px; font-size: 12px; }
.hqs-log summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.hqs-log-list { margin: 6px 0 0; padding-left: 18px; max-height: 180px; overflow: auto; font-size: 12px; }
.hqs-log-refused b { color: var(--st-blocked); }
.hqs-log-buffered b { color: var(--st-waiting); }
.hqs-log-applied b { color: var(--st-working); }

/* God View */
.hqs-god { margin-bottom: 14px; }
.hqs-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.hqs-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 9px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.hqs-tile-n { font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hqs-tile-l { font-size: 12px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.hqs-tile.is-zero .hqs-tile-n { color: var(--muted); font-weight: 500; }
.hqs-tile[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.tile-NEEDS_APPROVAL:not(.is-zero) { border-top: 3px solid var(--st-approval); }
.tile-BLOCKED:not(.is-zero) { border-top: 3px solid var(--st-blocked); }
.tile-ATTENTION:not(.is-zero) { border-top: 3px solid var(--st-attention); }
.tile-STALE:not(.is-zero) { border-top: 3px dashed var(--st-stale); }
.tile-active:not(.is-zero) { border-top: 3px solid var(--st-working); }
.tile-outcomes { box-shadow: none; background: transparent; }
.hqs-god-where { margin: 8px 0 0; }
.hqs-god-exec { margin: 4px 0 0; color: var(--muted); }
.hqs-room.is-wide { grid-column: span 2; }
.hqs-teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.hqs-teams > .hqs-area + .hqs-area { border-top: 0; margin-top: 0; }
.hqs-room > .hqs-area + .hqs-teams { border-top: 1px dashed var(--hqs-partition); margin-top: 8px; }

.hqs-body { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; align-items: start; }
.hqs-stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; }
.hqs-stage-bar { display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.hqs-check { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 500; font-size: 12px; }
.hqs-check input { width: auto; }
.hqs-map-opts { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.hqs-key { margin-left: auto; }
.hqs-key summary { cursor: pointer; color: var(--muted); }
.hqs-legend { list-style: none; padding: 6px 0 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text); }
.hqs-leg { display: inline-flex; gap: 4px; align-items: center; }
.hqs-leg .hqs-glyph, .hqs-chip .hqs-glyph, .hqs-mini .hqs-glyph, .hqs-tile-l .hqs-glyph { color: var(--st); font-weight: 700; }
/* Lines sit above room floors and beneath desks and headings, so they never strike through text. */
.hqs-lines { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 1; }
.hqs-token, .hqs-room-head, .hqs-owner, .hqs-team h5, .hqs-floor-label { position: relative; z-index: 2; }
.hqs-lines path { fill: none; stroke-width: 1.6; }
.ln-report { stroke: var(--text); opacity: .55; }
.ln-faint { opacity: .18; }
.ln-collaborates_with { stroke: var(--st-collab); stroke-dasharray: 6 4; stroke-width: 2; }
.ln-waiting_on { stroke: var(--st-waiting); stroke-dasharray: 2 4; stroke-width: 2; }
.ln-reviews { stroke: var(--st-review); stroke-dasharray: 8 3 2 3; stroke-width: 2; }

/* Map: organisation owner, floors, rooms (departments), areas (teams), desks (Workers). */
.hqs-owner { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); margin-bottom: 12px; width: fit-content; max-width: 100%; }
.hqs-owner-av { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; color: var(--surface); background: var(--text); }
.hqs-floor + .hqs-floor { margin-top: 16px; }
.hqs-floor-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; display: block; width: fit-content; background: var(--surface); }
.hqs-rooms { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.hqs-room { position: relative; background: var(--hqs-room); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; }
.hqs-room.is-active { box-shadow: inset 3px 0 0 var(--st-working); }
.hqs-room.is-selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.hqs-room-h { margin: 0; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); display: block; }
.hqs-room-head { background: var(--hqs-room); display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: baseline; margin-bottom: 6px; }
.hqs-room-name { border: 0; background: none; padding: 0; font-weight: 700; font-size: 15px; text-align: left; color: var(--text); }
.hqs-room-name:hover { text-decoration: underline; }
.hqs-room-head-sub { grid-column: 1; }
.hqs-room-sum { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.hqs-mini { font-size: 11px; display: inline-flex; gap: 4px; align-items: center; color: var(--text); }
.hqs-area { padding-top: 8px; }
.hqs-area + .hqs-area { border-top: 1px dashed var(--hqs-partition); margin-top: 8px; }
.hqs-team h5 { margin: 0 0 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hqs-desks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }

.hqs-token { width: 100%; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 0 9px; align-items: center;
  text-align: left; padding: 6px 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); transition: opacity .2s, border-color .2s; }
.hqs-token:hover { border-color: color-mix(in srgb, var(--st) 50%, var(--line)); }
.hqs-token:focus-visible, .hqs-tile:focus-visible, .hqs-room-name:focus-visible, .hqs-linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hqs-token[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.hqs-token .hqs-av { grid-row: 1 / span 2; }
.hqs-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.hqs-who b { font-size: 13px; }
.hqs-role { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hqs-st { grid-column: 2; font-size: 11px; font-weight: 600; color: color-mix(in srgb, var(--st) 80%, var(--text)); }
.hqs-token.is-hl { border-color: var(--text); box-shadow: 0 0 0 2px var(--text); }
.hqs-token.is-hl[aria-current="true"] { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px var(--text); }
.hqs [aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.hqs-table tr.is-hl th, .hqs-table tr.is-hl td { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.hqs-token.is-compact { width: auto; display: inline-grid; min-width: 210px; }
.hqs-token.st-STALE .hqs-av { filter: grayscale(1); }
.hqs-token.st-OFFLINE .hqs-av { filter: grayscale(.8); }

.hqs-av { position: relative; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: #fff; background: var(--tone, #64748b); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--st, var(--line)); }
.hqs-av.large { width: 52px; height: 52px; font-size: 18px; }
.st-STALE .hqs-av, .hqs-av.st-STALE { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--surface); outline: 2px dashed var(--st-stale); outline-offset: 2px; }
.hqs-badge { position: absolute; right: -6px; bottom: -6px; min-width: 19px; height: 19px; padding: 0 3px; border-radius: 10px; font-size: 11px; line-height: 19px;
  text-align: center; background: var(--st); color: var(--surface); border: 2px solid var(--surface); font-weight: 800; }
.tone-blue { --tone: #3b5bab; } .tone-green { --tone: #2f7a57; } .tone-amber { --tone: #9a6a1b; } .tone-violet { --tone: #6a4bb0; }
.tone-teal { --tone: #2a7d82; } .tone-rose { --tone: #a2465f; } .tone-slate { --tone: #556170; }

/* Motion only where execution evidence is fresh; never under reduced motion. */
.hqs-token.is-active .hqs-av::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 2px solid var(--st); opacity: 0;
  animation: hqs-pulse 2.4s ease-out infinite; }
@keyframes hqs-pulse { 0% { transform: scale(.85); opacity: .55; } 100% { transform: scale(1.18); opacity: 0; } }
.hqs-token.is-changed { animation: hqs-changed 1.4s ease-out 1; }
@keyframes hqs-changed { 0% { background: color-mix(in srgb, var(--st) 22%, var(--surface)); } 100% { background: var(--surface); } }
/* Pausing live updates also stops the pulse (WCAG 2.2.2). */
.hqs.is-paused .hqs-token.is-active .hqs-av::after { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .hqs-token.is-active .hqs-av::after, .hqs-token.is-changed { animation: none; }
  .hqs-token { transition: none; }
}

/* Hierarchy and list layouts */
.hqs-org, .hqs-org ul { list-style: none; margin: 0; padding-left: 22px; }
.hqs-org { padding-left: 0; }
.hqs-org li { position: relative; margin: 6px 0; }
.hqs-org ul { border-left: 1px solid var(--line); margin-left: 14px; }
.hqs-org ul > li::before { content: ""; position: absolute; left: -14px; top: 0; bottom: 50%; width: 12px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.hqs-listwrap { overflow-x: auto; }
.hqs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hqs-table caption { text-align: left; padding-bottom: 6px; }
.hqs-table th, .hqs-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hqs-table thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.hqs-chip { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--st) 55%, var(--line)); background: color-mix(in srgb, var(--st) 9%, var(--surface)); white-space: nowrap; }
.hqs-linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-align: left; }
.hqs-linkbtn:hover { text-decoration: underline; }

.hqs-feeds { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 4px; }
.hqs-feeds p { margin: 0 0 6px; }
.hqs-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.hqs-feed-when { display: block; }

/* Drill-down panel */
/* Scroll shadows show that the panel continues above or below. */
.hqs-panel { position: sticky; top: 12px;
  background: linear-gradient(var(--surface) 30%, transparent) top / 100% 24px no-repeat local,
    linear-gradient(transparent, var(--surface) 70%) bottom / 100% 24px no-repeat local,
    radial-gradient(farthest-side at 50% 0, var(--hqs-edge), transparent) top / 100% 8px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, var(--hqs-edge), transparent) bottom / 100% 8px no-repeat scroll,
    var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  max-height: calc(100vh - 24px); overflow: auto; box-shadow: var(--shadow); }
.hqs-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; padding: 0; font-size: 12px; }
.hqs-crumbs li + li::before { content: "\203A"; color: var(--muted); margin-right: 4px; }
.hqs-panel-title { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 10px; display: block; }
.hqs-sec { margin-top: 14px; }
.hqs-sec h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.hqs-sec p { margin: 2px 0; }
.hqs-facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 10px 0 0; font-size: 13px; }
.hqs-facts dt { color: var(--muted); }
.hqs-facts dd { margin: 0; }
.hqs-bullets { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
.hqs-bullets p { margin: 1px 0 0; }
.hqs-attn { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hqs-attn li { border-left: 3px solid var(--st); padding: 2px 0 2px 10px; }
.hqs-attn p { margin: 2px 0 0; }
.hqs-nc { margin: 2px 0; color: var(--muted); }
.hqs-nc-tag { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; color: var(--muted); }
.hqs-pulse { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.hqs-pulse li { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.hqs-pulse p { margin: 2px 0 0; }
.hqs-pulse-kind { display: block; text-transform: uppercase; letter-spacing: .06em; font-size: 10px; color: var(--muted); }
.hqs-adapters { margin-top: 14px; font-size: 12px; }
.hqs-adapters summary { cursor: pointer; color: var(--muted); }
.hqs-pf-head { display: flex; gap: 12px; align-items: center; }
.hqs-pf-role { font-weight: 600; margin: 0; }
.hqs-state-box { margin: 12px 0 0; padding: 8px 10px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--st) 40%, var(--line));
  background: color-mix(in srgb, var(--st) 6%, var(--surface)); }
.hqs-state-box p { margin: 4px 0 0; }
.hqs-state-box summary { cursor: pointer; margin-top: 4px; }
.hqs-rd { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 0 6px; border-radius: 5px; border: 1px solid var(--line); }
.hqs-rd.rd-ready { color: var(--st-working); border-color: var(--st-working); }
.hqs-rd.rd-connection_required, .hqs-rd.rd-licence_required, .hqs-rd.rd-approval_required { color: var(--st-waiting); border-color: var(--st-waiting); }
.hqs-rd.rd-blocked, .hqs-rd.rd-not_granted { color: var(--st-blocked); border-color: var(--st-blocked); }
.hqs-form { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.hqs-form h4 { margin: 0 0 4px; font-size: 14px; }
.hqs-form button { margin-top: 8px; }
.hqs-dl { margin-left: 6px; }

/* Progressive adaptation: the panel stacks, then the map becomes compact department lists. */
@media (max-width: 1100px) {
  .hqs-teams > .hqs-area + .hqs-area { border-top: 1px dashed var(--hqs-partition); }
  .hqs-body { grid-template-columns: minmax(0, 1fr); }
  .hqs-panel { position: static; max-height: none; }
}
@media (max-width: 640px) {
  /* Phones only: what needs attention comes before the long map (tablets keep the map first). */
  .hqs-body { display: flex; flex-direction: column; }
  .hqs-panel { order: -1; }
  .hqs-room.is-wide { grid-column: auto; }
  .hqs-rooms { grid-template-columns: minmax(0, 1fr); }
  .hqs-desks { grid-template-columns: minmax(0, 1fr); }
  .hqs-feeds { grid-template-columns: minmax(0, 1fr); }
  .hqs-legend { margin-left: 0; }
  .hqs-lines { display: none; }
  .hqs-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hqs-stage { padding: 10px; }
  .hqs-token.is-compact { min-width: 0; }
}
