/* SGI component layer.
 *
 * Framework-independent classes over canonical roles. React applies these
 * classes; a Jinja or raw-HTML surface may apply the same classes to the same
 * markup. Every colour, dimension and family below is a var(--sgi-…) into
 * the generated token stylesheet. No value is transcribed here.
 *
 * Interaction states the foundation does not define — hover, pressed,
 * selected, invalid-border — are not invented below.
 * GAP-INTERACTION-STATES, GAP-FOCUS-GEOMETRY and GAP-TOUCH-TARGETS are the
 * records; this file implements only what those records leave implementable.
 */

.sgi-surface,
.sgi-action,
.sgi-field,
.sgi-field-label,
.sgi-field-help,
.sgi-field-error,
.sgi-field-control-text,
.sgi-panel,
.sgi-panel-header,
.sgi-panel-title,
.sgi-status,
.sgi-table-wrap,
.sgi-table,
.sgi-table th,
.sgi-table td,
.sgi-frame,
.sgi-frame-chrome,
.sgi-frame-header,
.sgi-frame-canvas,
.sgi-frame-product,
.sgi-frame-mark,
.sgi-frame-nav,
.sgi-frame-nav a,
.sgi-app-switcher,
.sgi-app-switcher-trigger,
.sgi-app-switcher-glyph,
.sgi-app-switcher-panel,
.sgi-app-switcher-status,
.sgi-app-switcher-menu,
.sgi-app-switcher-item,
.sgi-app-switcher-name,
.sgi-app-switcher-meta,
.sgi-app-switcher-launcher,
.sgi-scope,
.sgi-scope-label,
.sgi-scope-value,
.sgi-text {
  box-sizing: border-box;
}

.sgi-surface {
  background: var(--sgi-color-ground);
  color: var(--sgi-color-ink-primary);
  font-family: var(--sgi-type-family-interface);
  font-size: var(--sgi-type-size-body);
  font-weight: var(--sgi-type-weight-body);
  line-height: var(--sgi-type-line-height-interface);
}

/* —— Typography ——————————————————————————————————————————————————————— */

.sgi-text {
  font-family: inherit;
  color: inherit;
  margin: 0;
}

.sgi-text--annotation {
  font-size: var(--sgi-type-size-annotation);
  color: var(--sgi-color-ink-tertiary);
}

.sgi-text--dense {
  font-size: var(--sgi-type-size-dense);
  color: var(--sgi-color-ink-primary);
}

.sgi-text--body {
  font-size: var(--sgi-type-size-body);
  line-height: var(--sgi-type-line-height-reading);
}

.sgi-text--title {
  font-size: var(--sgi-type-size-title);
  font-weight: var(--sgi-type-weight-structural);
}

.sgi-text--subhead {
  font-size: var(--sgi-type-size-subhead);
  font-weight: var(--sgi-type-weight-structural);
}

.sgi-text--heading {
  font-size: var(--sgi-type-size-heading);
  font-weight: var(--sgi-type-weight-structural);
  line-height: var(--sgi-type-line-height-tight);
}

.sgi-text--page-title {
  font-size: var(--sgi-type-size-page-title);
  font-weight: var(--sgi-type-weight-structural);
  line-height: var(--sgi-type-line-height-tight);
}

.sgi-text--promo {
  font-size: var(--sgi-type-size-promo);
  font-weight: var(--sgi-type-weight-structural);
  line-height: var(--sgi-type-line-height-tight);
}

.sgi-text--promo-large {
  font-size: var(--sgi-type-size-promo-large);
  font-weight: var(--sgi-type-weight-structural);
  line-height: var(--sgi-type-line-height-tight);
}

.sgi-text--secondary {
  color: var(--sgi-color-ink-secondary);
}

.sgi-text--measure {
  max-width: var(--sgi-type-measure-reading);
}

/* Identifier treatment is OQ-IDENTIFIER-TREATMENT. Do not add a code-face
   treatment here that pretends to settle it. */

/* —— Action ———————————————————————————————————————————————————————————— */

.sgi-action {
  /* Native appearance would paint a browser-default button when a
     reserved fill is invalid (RD-APPEARANCE-NONE). Actions only. */
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--sgi-density-control-height);
  padding-block: var(--sgi-space-step-tight);
  padding-inline: var(--sgi-space-step-loose);
  border-radius: var(--sgi-shape-radius-control);
  font-family: inherit;
  font-size: var(--sgi-type-size-dense);
  font-weight: var(--sgi-type-weight-strong);
  line-height: var(--sgi-type-line-height-tight);
  text-decoration: none;
  cursor: pointer;
}

.sgi-action--primary {
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-action-primary-fill);
  background: var(--sgi-color-action-primary-fill);
  color: var(--sgi-impl-action-primary-ink);
}

/* A deliberate call to action. Routine .sgi-action--primary stays the
   bound role, which is neutral gray on a staff surface. */
.sgi-action--cta {
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-accent-blue);
  background: var(--sgi-color-accent-blue);
  color: var(--sgi-color-ink-inverse);
}

.sgi-action--quiet {
  border: none;
  background: transparent;
  color: var(--sgi-color-action-primary-ink);
  text-decoration: underline;
  padding-inline: var(--sgi-space-step-snug);
}

/*
 * Minimum safe disabled behaviour: do not present a disabled action as
 * actionable. No invented disabled fill or ink (GAP-INTERACTION-STATES).
 */
.sgi-action:disabled {
  cursor: default;
}

/* Focus: two tones the foundation does define. Geometry uses the two
   dimension tokens as a derived stand-in for GAP-FOCUS-GEOMETRY. */
.sgi-action:focus-visible,
.sgi-field-control-text:focus-visible {
  outline: var(--sgi-shape-focus-ring-width) solid var(--sgi-color-focus-ring);
  outline-offset: var(--sgi-shape-focus-ring-offset);
  box-shadow: 0 0 0 var(--sgi-shape-focus-ring-width) var(--sgi-color-focus-contrast);
}

/* —— Field ————————————————————————————————————————————————————————————— */

.sgi-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--sgi-space-step-tight);
}

.sgi-field-label,
.sgi-field-help,
.sgi-field-error {
  font-family: inherit;
}

.sgi-field-label {
  font-size: var(--sgi-type-size-annotation);
  font-weight: var(--sgi-type-weight-strong);
  color: var(--sgi-color-ink-secondary);
}

.sgi-field-required {
  font-weight: var(--sgi-type-weight-strong);
}

/*
 * Text-like controls only. checkbox / radio / range / file / date and
 * other native types keep UA rendering (B4). appearance: none is not
 * applied here.
 */
.sgi-field-control-text {
  min-height: var(--sgi-density-control-height);
  padding-block: var(--sgi-space-step-tight);
  padding-inline: var(--sgi-space-step-snug);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-border-control);
  border-radius: var(--sgi-shape-radius-control);
  background: var(--sgi-color-surface-panel);
  color: var(--sgi-color-ink-primary);
  font-family: inherit;
  font-size: var(--sgi-type-size-dense);
}

.sgi-field-help,
.sgi-field-error {
  margin: 0;
  font-size: var(--sgi-type-size-annotation);
}

.sgi-field-help {
  color: var(--sgi-color-ink-secondary);
}

.sgi-field-error {
  color: var(--sgi-color-status-danger-ink);
}

/* Invalid border / fill is GAP-INTERACTION-STATES. Error is carried by the
   text equivalent and aria-invalid, not by an invented control state. */

/* —— Surface / panel ——————————————————————————————————————————————————— */

/*
 * Implementation presentation properties inherit from the nearest element
 * that declared the matching dimension. Fallbacks live on :root only —
 * a nested .sgi-surface resets only the dimensions it declares, so a
 * density-only or tenant-only surface must not restore these.
 *
 * Primary-action ink follows audience the same way fill already does
 * (--sgi-color-action-primary-fill). Both audiences use inverse ink:
 * staff on the achromatic fill, patient on Smile Group blue. An unbound
 * practice fill still fails visibly. data-sgi-unresolved is not a
 * rendering switch (RD-UNRESOLVED-ACTION-INK).
 */
:root {
  --sgi-impl-action-primary-ink: var(--sgi-color-ink-inverse);
  --sgi-impl-panel-edge: none;
  --sgi-impl-panel-border: none;
  --sgi-impl-panel-radius: 0;
  --sgi-impl-panel-padding: 0;
  --sgi-impl-panel-ground: transparent;
}

[data-sgi-audience='patient'] {
  --sgi-impl-action-primary-ink: var(--sgi-color-ink-inverse);
}

[data-sgi-audience='staff'] {
  --sgi-impl-action-primary-ink: var(--sgi-color-ink-inverse);
}

[data-sgi-register='framed'] {
  --sgi-impl-panel-edge: none;
  --sgi-impl-panel-border: none;
  --sgi-impl-panel-radius: var(--sgi-shape-radius-panel);
  --sgi-impl-panel-padding: var(--sgi-density-panel-padding);
  --sgi-impl-panel-ground: var(--sgi-color-surface-panel);
}

[data-sgi-register='contained'] {
  --sgi-impl-panel-edge: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-border-hairline);
  --sgi-impl-panel-border: var(--sgi-impl-panel-edge);
  --sgi-impl-panel-radius: var(--sgi-shape-radius-panel);
  --sgi-impl-panel-padding: var(--sgi-density-panel-padding);
  --sgi-impl-panel-ground: var(--sgi-color-surface-panel);
}

[data-sgi-register='bare'] {
  --sgi-impl-panel-edge: none;
  --sgi-impl-panel-border: none;
  --sgi-impl-panel-radius: 0;
  --sgi-impl-panel-padding: 0;
  --sgi-impl-panel-ground: transparent;
}

[data-sgi-content='prose'] {
  --sgi-impl-panel-border: none;
  --sgi-impl-panel-radius: 0;
  --sgi-impl-panel-padding: 0;
  --sgi-impl-panel-ground: transparent;
}

[data-sgi-content='objects'] {
  --sgi-impl-panel-border: var(--sgi-impl-panel-edge);
  --sgi-impl-panel-radius: var(--sgi-shape-radius-panel);
  --sgi-impl-panel-padding: var(--sgi-density-panel-padding);
  --sgi-impl-panel-ground: var(--sgi-color-surface-panel);
}

.sgi-panel {
  background: var(--sgi-impl-panel-ground);
  border: var(--sgi-impl-panel-border);
  border-radius: var(--sgi-impl-panel-radius);
  padding: var(--sgi-impl-panel-padding);
  color: inherit;
}

.sgi-panel--sunken {
  background: var(--sgi-color-surface-sunken);
}

.sgi-panel[data-sgi-panel='dissolved'] {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.sgi-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sgi-space-step-snug);
  min-height: var(--sgi-density-panel-header);
  margin-bottom: var(--sgi-density-section-gap);
}

.sgi-panel-title {
  margin: 0;
  font-family: inherit;
  font-size: var(--sgi-type-size-title);
  font-weight: var(--sgi-type-weight-structural);
}

/* —— Status ———————————————————————————————————————————————————————————— */

.sgi-status {
  font-family: inherit;
  font-size: var(--sgi-type-size-annotation);
  font-weight: var(--sgi-type-weight-strong);
}

.sgi-status--text {
  background: none;
  border: none;
  padding: 0;
}

.sgi-status--ok {
  color: var(--sgi-color-status-ok-ink);
}

.sgi-status--info {
  color: var(--sgi-color-status-info-ink);
}

.sgi-status--warn {
  color: var(--sgi-color-status-warn-ink);
}

.sgi-status--danger {
  color: var(--sgi-color-status-danger-ink);
}

.sgi-status--neutral {
  color: var(--sgi-color-status-neutral-ink);
}

.sgi-status--badge {
  display: inline-flex;
  align-items: center;
  min-height: var(--sgi-space-step-wide);
  padding-inline: var(--sgi-space-step-snug);
  border-radius: var(--sgi-shape-radius-control);
}

.sgi-status--badge.sgi-status--ok {
  background: var(--sgi-color-status-ok-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-ok-edge);
}

.sgi-status--badge.sgi-status--info {
  background: var(--sgi-color-status-info-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-info-edge);
}

.sgi-status--badge.sgi-status--warn {
  background: var(--sgi-color-status-warn-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-warn-edge);
}

.sgi-status--badge.sgi-status--danger {
  background: var(--sgi-color-status-danger-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-danger-edge);
}

.sgi-status--badge.sgi-status--neutral {
  background: var(--sgi-color-status-neutral-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-neutral-edge);
}

.sgi-status--banner {
  display: block;
  padding: var(--sgi-space-step-snug) var(--sgi-density-panel-padding);
  border-radius: var(--sgi-shape-radius-panel);
}

.sgi-status--banner.sgi-status--ok {
  background: var(--sgi-color-status-ok-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-ok-edge);
}

.sgi-status--banner.sgi-status--info {
  background: var(--sgi-color-status-info-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-info-edge);
}

.sgi-status--banner.sgi-status--warn {
  background: var(--sgi-color-status-warn-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-warn-edge);
}

.sgi-status--banner.sgi-status--danger {
  background: var(--sgi-color-status-danger-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-danger-edge);
}

.sgi-status--banner.sgi-status--neutral {
  background: var(--sgi-color-status-neutral-container);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-status-neutral-edge);
}

.sgi-status--on-frame {
  color: var(--sgi-color-status-neutral-on-frame);
}

.sgi-status--on-frame.sgi-status--ok {
  color: var(--sgi-color-status-ok-on-frame);
}

.sgi-status--on-frame.sgi-status--info {
  color: var(--sgi-color-status-info-on-frame);
}

.sgi-status--on-frame.sgi-status--warn {
  color: var(--sgi-color-status-warn-on-frame);
}

.sgi-status--on-frame.sgi-status--danger {
  color: var(--sgi-color-status-danger-on-frame);
}

/* —— Table ————————————————————————————————————————————————————————————— */

.sgi-table-wrap {
  overflow: auto;
}

.sgi-table-wrap:focus-visible {
  outline: var(--sgi-shape-focus-ring-width) solid var(--sgi-color-focus-ring);
  outline-offset: var(--sgi-shape-focus-ring-offset);
  box-shadow: 0 0 0 var(--sgi-shape-focus-ring-width) var(--sgi-color-focus-contrast);
}

.sgi-table {
  width: 100%;
  border-collapse: collapse;
  font-family: inherit;
  font-size: var(--sgi-type-size-dense);
}

.sgi-table th,
.sgi-table td {
  text-align: left;
  vertical-align: top;
  padding-block: var(--sgi-density-row-padding-block);
  padding-inline: var(--sgi-density-row-padding-inline);
  border-bottom: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-border-hairline);
  font-family: inherit;
}

.sgi-table th {
  font-weight: var(--sgi-type-weight-strong);
  color: var(--sgi-color-ink-secondary);
  font-size: var(--sgi-type-size-annotation);
}

.sgi-table-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sgi-table tr[data-sgi-status='danger'] {
  background: var(--sgi-color-status-tint-danger);
}

/* Warn row tint exists as a token and is OQ-TINT-BANDS. Do not apply it
   here as if the band count were decided. */

.sgi-table caption {
  caption-side: top;
  text-align: left;
  font-size: var(--sgi-type-size-annotation);
  color: var(--sgi-color-ink-secondary);
  padding-bottom: var(--sgi-space-step-snug);
}

/* —— Frame and scope ——————————————————————————————————————————————————— */

/*
 * Staff framed chrome (M1). From 901px up this is the two-column shell
 * (280px, or 72px when collapsed). At 900px and below it is a drawer
 * (RD-FRAME-DESKTOP, DEC-36). That replaces the 0.2.0 compact top bar at
 * 768px. An estate-wide breakpoint scale remains GAP-BREAKPOINTS. This
 * grid is not a claim on M9. See REACT.md.
 */
.sgi-frame {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
  background: var(--sgi-color-frame-base);
  transition: grid-template-columns 0.22s ease;
}

.sgi-frame,
.sgi-frame *,
.sgi-frame *::before,
.sgi-frame *::after {
  box-sizing: border-box;
}

.sgi-frame-chrome {
  display: flex;
  flex-direction: column;
  gap: var(--sgi-space-step-loose);
  background: var(--sgi-color-frame-base);
  color: var(--sgi-color-frame-ink-primary);
  padding: var(--sgi-space-step-loose);
}

.sgi-frame-product {
  font-family: inherit;
  font-size: var(--sgi-type-size-title);
  font-weight: var(--sgi-type-weight-structural);
  color: var(--sgi-color-frame-ink-primary);
}

.sgi-frame-mark {
  /* color.identity.mark.onFrame is a reserved slot (OQ-ACCENT-HUE).
     A consumer built from the foundation alone renders no chromatic mark
     and no user-visible placeholder. */
}

.sgi-frame-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sgi-space-step-snug);
  color: var(--sgi-color-frame-ink-secondary);
  font-family: inherit;
  font-size: var(--sgi-type-size-dense);
}

.sgi-frame-nav [aria-current='page'] {
  color: var(--sgi-color-frame-ink-primary);
  font-weight: var(--sgi-type-weight-strong);
}

.sgi-frame-canvas {
  background: var(--sgi-color-ground);
  color: var(--sgi-color-ink-primary);
  padding: var(--sgi-space-gutter);
}

.sgi-scope {
  background: var(--sgi-color-scope-base);
  color: var(--sgi-color-scope-ink-primary);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-scope-edge);
  padding: var(--sgi-space-step-snug) var(--sgi-space-step-base);
  font-family: inherit;
  font-size: var(--sgi-type-size-annotation);
}

.sgi-scope-label {
  display: block;
  color: var(--sgi-color-scope-ink-secondary);
}

.sgi-scope-value {
  display: block;
  font-weight: var(--sgi-type-weight-strong);
  color: var(--sgi-color-scope-ink-primary);
}

/* Tenant identity stays in the scope strip. Do not recolour .sgi-frame
   or .sgi-frame-canvas from a tenant or practice brand. INV-TENANT-NO-REACH. */

/* —— App switcher ——————————————————————————————————————————————————————— */

/*
 * Shared staff app switcher. The classes are the whole contract a Go or
 * static shell needs; packages/react/src/css/sgi-app-switcher.js mounts them.
 * Colours, type, space, radius and the one elevation are existing tokens.
 * No accent hue: staff routine actions stay achromatic, and a product mark
 * is not drawn here (OQ-ACCENT-HUE).
 *
 * The default .sgi-frame is the Stats shell: a sidebar and a white top bar.
 * .sgi-frame-header remains for a consumer that still mounts the 9-dot.
 * .sgi-frame--bar is an opt-in thin top bar at every width. The staff-frame
 * breakpoint is 900px (DEC-36), which replaces the 0.2.0 collapse at 768px.
 * GAP-BREAKPOINTS still covers an estate-wide scale. The 9-dot is not
 * mounted in the frame; the nested sidebar is the app list.
 *
 * The panel is position: absolute so it paints with positioned content,
 * above the in-flow canvas, without a z-index. There is no layering scale
 * (GAP-ZINDEX). Hover, pressed and selected fills are not invented
 * (GAP-INTERACTION-STATES). Focus reuses the two focus tones
 * (RD-FOCUS-GEOMETRY). The trigger uses the density control height; a
 * larger touch target is GAP-TOUCH-TARGETS.
 */

.sgi-frame-header {
  display: flex;
  align-items: center;
  gap: var(--sgi-space-step-snug);
  min-width: 0;
  min-height: var(--sgi-density-control-height);
}

.sgi-frame-header > .sgi-frame-product {
  min-width: 0;
}

.sgi-frame--bar {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
}

.sgi-frame--bar > .sgi-frame-chrome {
  flex-direction: row;
  align-items: center;
  gap: var(--sgi-space-step-loose);
  padding-block: var(--sgi-space-step-snug);
}

.sgi-frame--bar > .sgi-frame-chrome > .sgi-frame-nav {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  margin-inline-start: auto;
}

.sgi-app-switcher {
  position: relative;
  flex: 0 0 auto;
  font-family: var(--sgi-type-family-interface);
}

.sgi-app-switcher-trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--sgi-density-control-height);
  height: var(--sgi-density-control-height);
  padding: 0;
  border: none;
  border-radius: var(--sgi-shape-radius-control);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sgi-app-switcher-glyph {
  display: grid;
  grid-template-columns: repeat(3, var(--sgi-space-step-tight));
  gap: var(--sgi-space-step-hair);
  color: inherit;
}

.sgi-app-switcher-glyph > span {
  display: block;
  width: var(--sgi-space-step-tight);
  height: var(--sgi-space-step-tight);
  border-radius: var(--sgi-shape-radius-circle);
  background: currentColor;
}

.sgi-app-switcher-panel {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + var(--sgi-space-step-tight));
  display: flex;
  flex-direction: column;
  min-width: 15rem;
  max-width: min(20rem, 70vw);
  max-height: 70vh;
  overflow: auto;
  background: var(--sgi-color-surface-panel);
  color: var(--sgi-color-ink-primary);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-border-hairline);
  border-radius: var(--sgi-shape-radius-panel);
  box-shadow: var(--sgi-shape-elevation-float);
  font-family: inherit;
  font-size: var(--sgi-type-size-dense);
  font-weight: var(--sgi-type-weight-body);
  line-height: var(--sgi-type-line-height-interface);
}

.sgi-app-switcher-panel[hidden] {
  display: none;
}

.sgi-app-switcher-status {
  margin: 0;
  padding: var(--sgi-space-step-snug) var(--sgi-space-step-snug) 0;
  color: var(--sgi-color-ink-secondary);
  font-size: var(--sgi-type-size-annotation);
}

.sgi-app-switcher-status:empty {
  display: none;
}

.sgi-app-switcher-menu {
  display: flex;
  flex-direction: column;
  gap: var(--sgi-space-step-hair);
  margin: 0;
  padding: var(--sgi-space-step-tight);
}

.sgi-app-switcher-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sgi-space-step-hair);
  padding: var(--sgi-space-step-tight) var(--sgi-space-step-snug);
  border-radius: var(--sgi-shape-radius-control);
  color: var(--sgi-color-ink-primary);
  font: inherit;
  font-size: var(--sgi-type-size-dense);
  line-height: var(--sgi-type-line-height-tight);
  text-decoration: none;
  cursor: pointer;
}

.sgi-app-switcher-name {
  font-weight: var(--sgi-type-weight-body);
}

.sgi-app-switcher-meta {
  color: var(--sgi-color-ink-tertiary);
  font-size: var(--sgi-type-size-annotation);
  font-weight: var(--sgi-type-weight-body);
}

.sgi-app-switcher-item[aria-current='page'] .sgi-app-switcher-name {
  font-weight: var(--sgi-type-weight-strong);
}

.sgi-app-switcher-launcher {
  margin-top: var(--sgi-space-step-tight);
  padding-top: var(--sgi-space-step-snug);
  border-top: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-border-hairline);
  border-radius: 0;
  color: var(--sgi-color-ink-secondary);
  text-decoration: underline;
}

.sgi-app-switcher-trigger:focus-visible,
.sgi-app-switcher-item:focus-visible {
  outline: var(--sgi-shape-focus-ring-width) solid var(--sgi-color-focus-ring);
  outline-offset: var(--sgi-shape-focus-ring-offset);
  box-shadow: 0 0 0 var(--sgi-shape-focus-ring-width) var(--sgi-color-focus-contrast);
}

/* —— Staff shell (DEC-36) ——————————————————————————————————————————————
   Desktop: 280px sidebar, or a locked 72px rail when [data-collapsed="true"].
   The rail clips horizontal overflow, shows the icon mark, and keeps every
   category as a monogram. At 900px and below the sidebar is a drawer.
   The top bar is white.
   The one elevation is used for the drawer and the user menu. A shadow
   on the in-flow main column is not added: a shadow in flow is a defect,
   and 14px was rejected as a second radius family, so the main column
   uses the panel radius. The app switcher above is not mounted in this
   shell; the nested sidebar is the only app list. */

.sgi-frame-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background: var(--sgi-color-surface-canvas);
  border-top-left-radius: var(--sgi-shape-radius-panel);
}

.sgi-frame-topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 48px;
  padding: 8px 12px;
  background: var(--sgi-color-surface-panel);
  color: var(--sgi-color-ink-primary);
  border-bottom: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-border-bar);
}

.sgi-frame-title {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--sgi-type-size-dense);
  font-weight: var(--sgi-type-weight-structural);
  line-height: var(--sgi-type-line-height-tight);
}

.sgi-frame-menu,
.sgi-frame-collapse {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sgi-color-ink-primary);
  cursor: pointer;
}

.sgi-frame-menu {
  display: none;
}

.sgi-frame-collapse svg {
  display: block;
  transition: transform 0.22s ease;
}

/* Expanded points left. Collapsed mirrors it so the control reads as expand. */
.sgi-frame[data-collapsed='true'] .sgi-frame-collapse svg {
  transform: scaleX(-1);
}

.sgi-frame-menu:focus-visible,
.sgi-frame-collapse:focus-visible,
.sgi-frame-avatar:focus-visible,
.sgi-nav-section-toggle:focus-visible,
.sgi-frame-nav a:focus-visible,
.sgi-frame-user-menu [role='menuitem']:focus-visible {
  outline: var(--sgi-shape-focus-ring-width) solid var(--sgi-color-focus-ring);
  outline-offset: var(--sgi-shape-focus-ring-offset);
  box-shadow: 0 0 0 var(--sgi-shape-focus-ring-width) var(--sgi-color-focus-contrast);
}

.sgi-frame-user {
  position: relative;
  margin-inline-start: auto;
  flex: 0 0 auto;
}

.sgi-frame-avatar {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--sgi-shape-radius-circle);
  background: var(--sgi-color-accent-blue);
  color: var(--sgi-color-ink-inverse);
  font-size: 11px;
  font-weight: var(--sgi-type-weight-structural);
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
}

.sgi-frame-avatar img {
  width: 30px;
  height: 30px;
  border-radius: var(--sgi-shape-radius-circle);
  object-fit: cover;
}

.sgi-frame-avatar:hover {
  box-shadow: var(--sgi-shape-elevation-float);
}

.sgi-frame-avatar[aria-expanded='true'] {
  box-shadow:
    0 0 0 var(--sgi-shape-focus-ring-width) var(--sgi-color-surface-panel),
    0 0 0 calc(var(--sgi-shape-focus-ring-width) * 2) var(--sgi-color-accent-blue);
}

.sgi-frame-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  background: var(--sgi-color-surface-panel);
  color: var(--sgi-color-ink-primary);
  border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-border-hairline);
  border-radius: 10px;
  box-shadow: var(--sgi-shape-elevation-float);
}

.sgi-frame-user-menu[hidden] {
  display: none;
}

.sgi-frame-user-name,
.sgi-frame-user-email {
  margin: 0;
  padding: 10px 12px 0;
}

.sgi-frame-user-name {
  font-size: var(--sgi-type-size-dense);
  font-weight: var(--sgi-type-weight-strong);
}

.sgi-frame-user-email {
  padding-bottom: 10px;
  border-bottom: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-surface-canvas);
  color: var(--sgi-color-ink-secondary);
  font-size: var(--sgi-type-size-annotation);
  word-break: break-all;
}

.sgi-frame-signout {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--sgi-color-accent-blue);
  font: inherit;
  font-size: var(--sgi-type-size-dense);
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.sgi-frame-chrome {
  min-width: 0;
  gap: 0;
  padding: 0;
  overflow: auto;
}

.sgi-frame-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 6px 5px;
  border-bottom: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-frame-edge);
  background: var(--sgi-color-frame-base);
}

.sgi-frame-logo img.sgi-frame-logo-wide {
  display: block;
  width: 100%;
  max-height: 56px;
  object-fit: contain;
  object-position: left center;
}

.sgi-frame-logo img.sgi-frame-logo-mark {
  display: none;
  width: 44px;
  height: 44px;
  max-height: none;
  object-fit: cover;
  object-position: 17% 50%;
}

.sgi-frame-nav {
  gap: 0;
  padding: 8px 0 16px;
}

.sgi-nav-section-toggle {
  appearance: none;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--sgi-color-frame-ink-secondary);
  font: inherit;
  font-size: var(--sgi-type-size-dense);
  text-align: start;
  cursor: pointer;
}

.sgi-nav-section-toggle:hover {
  color: var(--sgi-color-ink-inverse);
  background: var(--sgi-color-frame-hover);
}

.sgi-nav-section-abbr {
  display: none;
}

.sgi-nav-chevron {
  margin-inline-start: auto;
  flex: 0 0 auto;
}

.sgi-nav-section-list {
  display: flex;
  flex-direction: column;
}

.sgi-nav-section-toggle[aria-expanded='false'] + .sgi-nav-section-list {
  display: none;
}

.sgi-frame-nav a {
  padding: 7px 14px 7px 22px;
  color: var(--sgi-color-frame-ink-tertiary);
  font-size: var(--sgi-type-size-dense);
  text-decoration: none;
}

.sgi-frame-nav a:hover {
  color: var(--sgi-color-accent-teal);
}

.sgi-frame-nav a[aria-current='page'] {
  color: var(--sgi-color-ink-inverse);
  font-weight: var(--sgi-type-weight-strong);
  background: var(--sgi-color-frame-current);
  box-shadow: inset 3px 0 0 var(--sgi-color-accent-teal);
}

.sgi-frame-backdrop {
  display: none;
}

.sgi-frame .sgi-scope {
  background: var(--sgi-color-surface-panel);
  color: var(--sgi-color-ink-primary);
  border-color: var(--sgi-color-border-hairline);
}

.sgi-frame .sgi-scope-label {
  color: var(--sgi-color-ink-secondary);
}

.sgi-frame .sgi-scope-value {
  color: var(--sgi-color-ink-primary);
}

/*
 * Desktop rail only. At 900px and below the sidebar is a drawer, and these
 * rules must not pin that drawer to 72px. The grid track and the chrome
 * share one locked width: min-width stops the column shrinking under its
 * content, and overflow-x: hidden stops the horizontal scrollbar.
 *
 * The wide logo's icon is the 72×72 square at viewBox (54, 36) inside
 * 504×144. 44px × 90/72 is the icon's centre in that scale, so the image
 * is shifted until that centre sits in the middle of the 72px rail.
 * The rail clips the rest, which is where the wordmark lives.
 */
@media (min-width: 901px) {
  .sgi-frame[data-collapsed='true'] {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .sgi-frame[data-collapsed='true'] .sgi-frame-chrome {
    width: 72px;
    min-width: 72px;
    max-width: 72px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .sgi-frame[data-collapsed='true'] .sgi-frame-logo {
    position: relative;
    display: block;
    width: 72px;
    height: 64px;
    padding: 0;
    overflow: hidden;
  }

  .sgi-frame[data-collapsed='true'] .sgi-frame-logo img.sgi-frame-logo-wide {
    display: none;
  }

  .sgi-frame[data-collapsed='true'] .sgi-frame-logo img.sgi-frame-logo-mark {
    display: block;
    position: absolute;
    width: calc(44px * 504 / 72);
    height: calc(44px * 144 / 72);
    max-width: none;
    max-height: none;
    left: calc(50% - 44px * 90 / 72);
    top: calc(50% - 44px);
    object-fit: fill;
    object-position: left top;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section-toggle {
    position: relative;
    justify-content: center;
    width: 72px;
    max-width: 72px;
    min-height: 44px;
    padding: 0;
    overflow: hidden;
    text-align: center;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-chevron {
    display: none;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section-abbr {
    display: block;
    font-size: var(--sgi-type-size-title);
    font-weight: var(--sgi-type-weight-structural);
    letter-spacing: 0.04em;
    line-height: 1;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section-list {
    display: none;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section:hover .sgi-nav-section-list,
  .sgi-frame[data-collapsed='true'] .sgi-nav-section:focus-within .sgi-nav-section-list {
    display: flex;
    position: fixed;
    left: 72px;
    top: auto;
    z-index: 6;
    min-width: 200px;
    max-width: 280px;
    max-height: min(70vh, calc(100vh - 16px));
    overflow: auto;
    background: var(--sgi-color-frame-base);
    border: var(--sgi-shape-border-width-hairline) solid var(--sgi-color-frame-edge);
    box-shadow: var(--sgi-shape-elevation-float);
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section {
    position: relative;
  }

  .sgi-frame[data-collapsed='true'] .sgi-frame-nav a {
    white-space: nowrap;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section:has(a[aria-current='page']) .sgi-nav-section-toggle {
    color: var(--sgi-color-ink-inverse);
    box-shadow: inset 3px 0 0 var(--sgi-color-accent-teal);
  }
}

@media (max-width: 900px) {
  .sgi-frame,
  .sgi-frame[data-collapsed='true'] {
    grid-template-columns: minmax(0, 1fr);
  }

  .sgi-frame-main {
    border-top-left-radius: 0;
  }

  .sgi-frame-collapse {
    display: none;
  }

  .sgi-frame--enhanced .sgi-frame-menu {
    display: inline-flex;
  }

  .sgi-frame--enhanced .sgi-frame-chrome {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 4;
    width: min(300px, 92vw);
    min-width: 0;
    max-width: none;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    overflow: auto;
  }

  .sgi-frame--nav-open .sgi-frame-chrome,
  .sgi-frame[data-nav-open] .sgi-frame-chrome {
    transform: translateX(0);
    box-shadow: var(--sgi-shape-elevation-float);
  }

  .sgi-frame--nav-open .sgi-frame-backdrop,
  .sgi-frame[data-nav-open] .sgi-frame-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 3;
    background: var(--sgi-color-ink-primary);
    opacity: 0.45;
  }

  .sgi-frame[data-collapsed='true'] .sgi-frame-logo img.sgi-frame-logo-wide,
  .sgi-frame--nav-open .sgi-frame-logo img.sgi-frame-logo-wide,
  .sgi-frame[data-nav-open] .sgi-frame-logo img.sgi-frame-logo-wide {
    display: block;
  }

  .sgi-frame[data-collapsed='true'] .sgi-frame-logo img.sgi-frame-logo-mark {
    display: none;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section-label,
  .sgi-frame[data-collapsed='true'] .sgi-nav-chevron {
    display: inline;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section-abbr {
    display: none;
  }

  .sgi-frame[data-collapsed='true'] .sgi-nav-section-list {
    position: static;
    min-width: 0;
    border: none;
    box-shadow: none;
  }

  .sgi-nav-section-toggle[aria-expanded='true'] + .sgi-nav-section-list {
    display: flex;
  }
}

html.sgi-nav-lock {
  overflow: hidden;
}

.sgi-frame-canvas {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-wrap: anywhere;
}

.sgi-frame-canvas .sgi-table-wrap,
.sgi-frame-canvas table {
  max-width: 100%;
}
