/* Specture portal. Tokens first, then layout, then components.
   Colors follow the validated data-viz palette: status colors are fixed (never themed),
   chart chrome and ink swap with the theme. The 3D viewport stays dark in both themes so
   the status colors keep their contrast. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-fill: #2468bd; /* filled controls: white text on it is 5.5:1 */
  --accent-text: #1f64b8; /* accent-colored text on the surface: 5.7:1 */
  --danger-ink: #d03b3b; /* error text on the surface: 4.7:1 */
  --accent-wash: rgba(42, 120, 214, 0.1);
  --track: #cde2fb; /* blue 100: the lighter step of the fill's own ramp */
  --warning: #fab219;
  --hover: rgba(11, 11, 11, 0.05);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 8px 24px rgba(11, 11, 11, 0.08);

  /* Status colors: fixed in both themes. */
  --s-designed: #898781;
  --s-ordered: #184f95;
  --s-transit: #3987e5;
  --s-installed: #86b6ef;
  --s-delayed: #d03b3b;

  --viewport: #0d0d0d;
  --viewport-ink: #f0efec;
  --viewport-muted: #c3c2b7;
  --viewport-chrome: rgba(26, 26, 25, 0.86);
  --viewport-border: rgba(255, 255, 255, 0.14);

  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --accent-fill: #1d5fb5;
    --accent-text: #5596ea;
    --danger-ink: #f06a6a;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --track: #0d366b; /* blue 700 */
    --hover: rgba(255, 255, 255, 0.06);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --accent-fill: #1d5fb5;
  --accent-text: #5596ea;
  --danger-ink: #f06a6a;
  --accent-wash: rgba(57, 135, 229, 0.16);
  --track: #0d366b;
  --hover: rgba(255, 255, 255, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- App shell ---------------------------------------------------------- */

/* Desktop: the app is exactly the viewport tall, so the 3D view and the side column share a
   definite height (the side column scrolls inside it instead of stretching the page). */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  letter-spacing: 0.01em;
  margin-right: 8px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 2px;
  align-items: stretch;
  height: 100%;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
}
.tab:hover {
  color: var(--ink);
  background: var(--hover);
}
.tab[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.tab svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.spacer {
  flex: 1;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-2);
}
.icon-button:hover {
  background: var(--hover);
  color: var(--ink);
}
.icon-button svg {
  width: 16px;
  height: 16px;
}

.tools {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
/* The hidden workbench keeps its size (invisible, not display:none): the 3D canvas would otherwise
   shrink to 0x0 and the viewer would log WebGL framebuffer errors on every tab switch. */
.view.workbench[hidden] {
  display: flex;
  visibility: hidden;
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.view[hidden] {
  display: none;
}
.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Workbench ---------------------------------------------------------- */

.workbench {
  padding: 16px;
  gap: 12px;
  overflow: auto;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 0;
}
.tile-label {
  color: var(--ink-2);
  font-size: 12px;
}
.tile-value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  margin-top: 2px;
}
.tile-sub {
  color: var(--ink-2);
  font-size: 12px;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tile-value .unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  margin-left: 3px;
}

.meter {
  height: 6px;
  border-radius: 3px;
  background: var(--track);
  margin-top: 8px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}
.meter-fill[data-severity='warning'] {
  background: var(--warning);
}
.meter-fill[data-severity='danger'] {
  background: var(--s-delayed);
}

.status-band {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.statusbar {
  display: flex;
  gap: 2px;
  height: 16px;
}
.statusbar-seg {
  flex: 0 0 auto;
  min-width: 0;
  border: 0;
  padding: 0;
  height: 16px;
  background: var(--seg);
  cursor: pointer;
  transition:
    filter 120ms,
    opacity 120ms;
}
.statusbar-seg:first-child {
  border-radius: 4px 0 0 4px;
}
.statusbar-seg:last-child {
  border-radius: 0 4px 4px 0;
}
.statusbar-seg:only-child {
  border-radius: 4px;
}
.statusbar-seg:hover,
.statusbar-seg:focus-visible {
  filter: brightness(1.18);
}
.statusbar[data-filtering='true'] .statusbar-seg:not([data-active='true']) {
  opacity: 0.35;
}
.statusbar-empty {
  color: var(--ink-2);
  font-size: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
}
.chip:hover {
  background: var(--hover);
}
.chip[aria-pressed='true'] {
  background: var(--accent-wash);
  border-color: var(--accent);
}
.chip svg {
  width: 14px;
  height: 14px;
  color: var(--c);
  flex: none;
}
.chip-count {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.chip-task {
  padding-right: 6px;
}

.filter-field {
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--page);
  padding: 0 8px;
  min-width: 0;
}
.filter-spacer {
  flex: 1;
}
.filter-summary {
  color: var(--ink-2);
  font-size: 12px;
}

.work {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr);
  gap: 12px;
  flex: 1 1 0;
  min-height: 560px;
}
.work > * {
  min-height: 0;
}

.viewer-card {
  position: relative;
  background: var(--viewport);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 420px;
  border: 1px solid var(--border);
}
.viewer-host {
  position: absolute;
  inset: 0;
}
.viewer-mount {
  position: absolute;
  inset: 0;
}
.viewer-host canvas {
  display: block;
  outline: none;
}

.viewer-overlay {
  position: absolute;
  display: flex;
  gap: 6px;
  align-items: center;
  z-index: 2;
  background: var(--viewport-chrome);
  color: var(--viewport-ink);
  border: 1px solid var(--viewport-border);
  border-radius: 6px;
  padding: 4px;
  backdrop-filter: blur(6px);
}
.viewer-overlay[hidden] {
  display: none;
}
.viewer-overlay.top-right {
  top: 10px;
  right: 10px;
}
.viewer-overlay.bottom-left {
  bottom: 10px;
  left: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--viewport-muted);
  max-width: calc(100% - 20px);
}
.viewer-button {
  background: transparent;
  border: 0;
  color: var(--viewport-ink);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
}
.viewer-button:hover {
  background: rgba(255, 255, 255, 0.1);
}
.viewer-button[aria-pressed='true'] {
  background: rgba(255, 255, 255, 0.18);
}

.viewer-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--viewport-muted);
  padding: 24px;
  z-index: 1;
  pointer-events: none;
}
.viewer-message[hidden] {
  display: none;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  overflow-y: auto;
}
.side > .card {
  flex: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--grid);
  font-weight: 600;
}
.card-head .muted {
  font-weight: 400;
}
.card-body {
  padding: 12px 16px;
}
.muted {
  color: var(--ink-2);
}

/* Detail form */
.detail-title {
  font-weight: 600;
  font-size: 15px;
}
.detail-sub {
  color: var(--ink-2);
  font-size: 12px;
  margin-top: 2px;
}
.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 12px 0;
}
.fact-label {
  color: var(--ink-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fact-value {
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.field.wide {
  grid-column: 1 / -1;
}
.field label {
  font-size: 12px;
  color: var(--ink-2);
}
.field input,
.field select,
.field textarea {
  border: 1px solid var(--axis);
  background: var(--page);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 0;
  width: 100%;
}
.field textarea {
  resize: vertical;
  min-height: 56px;
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.button {
  border: 1px solid var(--axis);
  background: transparent;
  border-radius: 6px;
  padding: 6px 14px;
  font-weight: 500;
}
.button:hover {
  background: var(--hover);
}
.button.primary {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--accent-ink);
}
.button.primary:hover {
  filter: brightness(1.08);
}
.button:disabled {
  opacity: 0.5;
  cursor: default;
}
.form-message {
  font-size: 12px;
  color: var(--ink-2);
}
.form-message[data-kind='error'] {
  color: var(--danger-ink);
}
.form-message[data-kind='ok'] {
  color: var(--ink-2);
}
.hint {
  color: var(--ink-2);
  padding: 16px;
}

/* Table */
.table-wrap {
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.side > .table-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 220px;
}
table.elements {
  width: 100%;
  border-collapse: collapse;
}
.elements th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: left;
  font-weight: 500;
  color: var(--ink-2);
  font-size: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--axis);
  white-space: nowrap;
}
.elements th button {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-weight: inherit;
}
.elements th button:hover {
  color: var(--ink);
}
.elements td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
}
.elements tbody tr {
  cursor: pointer;
}
.elements tbody tr:hover {
  background: var(--hover);
}
.elements tbody tr[aria-selected='true'] {
  background: var(--accent-wash);
  box-shadow: inset 2px 0 0 var(--accent);
}
.elements .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cell-name {
  font-weight: 500;
}
.cell-sub {
  color: var(--ink-2);
  font-size: 12px;
}
.status-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.status-cell svg,
.status-icon {
  width: 14px;
  height: 14px;
  color: var(--c);
  flex: none;
}
.table-note {
  padding: 8px 16px;
  color: var(--ink-2);
  font-size: 12px;
}
.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--ink-2);
}

/* Schedule */
.task {
  padding: 8px 16px;
  border-bottom: 1px solid var(--grid);
  cursor: pointer;
}
.task:last-child {
  border-bottom: 0;
}
.task:hover {
  background: var(--hover);
}
.task[aria-pressed='true'] {
  background: var(--accent-wash);
  box-shadow: inset 2px 0 0 var(--accent);
}
.task-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-name {
  font-weight: 500;
  flex: 1;
  min-width: 0;
}
.task-meta {
  color: var(--ink-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.task .meter {
  margin-top: 6px;
  height: 4px;
}
details.card > summary {
  list-style: none;
  cursor: pointer;
}
details.card > summary::-webkit-details-marker {
  display: none;
}
details.card > summary .chev {
  margin-left: auto;
  transition: transform 120ms;
}
details.card[open] > summary .chev {
  transform: rotate(90deg);
}

.is-loading {
  opacity: 0.6;
  transition: opacity 120ms;
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  box-shadow: var(--shadow);
  font-size: 12px;
}
.tooltip[hidden] {
  display: none;
}
.tooltip-value {
  font-weight: 600;
  font-size: 13px;
}
.tooltip-label {
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tooltip-key {
  width: 10px;
  height: 3px;
  border-radius: 2px;
  background: var(--c);
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: var(--page);
  border-radius: 6px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
}
.toast[hidden] {
  display: none;
}

/* ---- Embedded tools ----------------------------------------------------- */

.embed {
  padding: 0;
}
.embed-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 13px;
}
.embed-bar a {
  color: var(--accent-text);
}
.embed-frame {
  flex: 1;
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: var(--surface);
}
.link-card {
  margin: 48px auto;
  max-width: 560px;
  text-align: center;
  padding: 32px;
}
.link-card a.button {
  display: inline-block;
  text-decoration: none;
  margin-top: 12px;
}

.banner {
  border: 1px solid var(--border);
  border-left: 3px solid var(--s-delayed);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 16px;
  color: var(--ink);
}
.banner[hidden] {
  display: none;
}

/* ---- Home --------------------------------------------------------------- */

.home {
  overflow: auto;
  padding: 24px 16px 32px;
}
.home-page {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.home-intro {
  max-width: 70ch;
}
.home-title {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0.005em;
}
.home-lead {
  margin: 0;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.5;
}
.home-heading {
  margin: 10px 0 0;
  font-size: 15px;
  font-weight: 650;
}
.home-section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.home-section-head .home-heading {
  margin: 0;
}
.home-summary {
  font-size: 13px;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.home-grid > .home-card {
  grid-column: span 2;
}
.home-grid > .home-card:nth-last-child(-n + 2) {
  grid-column: span 3;
} /* five cards: three on top, two wider below */
.home-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
}
.home-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.home-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}
.home-kind {
  font-size: 12px;
  text-align: right;
}
.home-card p {
  margin: 0;
}
.home-text {
  color: var(--ink-2);
  flex: 1;
}
.home-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.home-status svg {
  width: 14px;
  height: 14px;
  flex: none;
}
.home-status[data-state='up'] svg {
  color: var(--accent-text);
}
.home-status[data-state='down'] {
  color: var(--danger-ink);
}
.home-status[data-state='checking'],
.home-status[data-state='unknown'] {
  color: var(--ink-2);
}
.home-detail {
  font-size: 12px;
  min-height: 1.45em;
  overflow-wrap: anywhere;
}
.home-hint {
  font-size: 12px;
}
.home-card a.button {
  align-self: flex-start;
  text-decoration: none;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  color: inherit;
}
.home-help {
  font-size: 13px;
  margin: 0;
}
.home-help[hidden] {
  display: none;
}
.home-help code {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 12px;
  background: var(--hover);
  padding: 1px 5px;
  border-radius: 4px;
}
.home-steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.home-step {
  counter-increment: step;
  position: relative;
  padding: 12px 14px 12px 52px;
  min-height: 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.home-step::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  font-size: 13px;
  background: var(--accent-fill);
  color: var(--accent-ink);
}
.home-step p {
  margin: 2px 0 0;
  font-size: 12.5px;
}
.home-step-title {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.home-step-title:hover {
  text-decoration: underline;
}

/* ---- Narrow screens ----------------------------------------------------- */

@media (max-width: 1100px) {
  /* Stacked layout: normal page flow, the page scrolls. */
  .app {
    height: auto;
    min-height: 100%;
  }
  .workbench,
  .home {
    overflow: visible;
  }
  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-grid > .home-card,
  .home-grid > .home-card:nth-last-child(-n + 2) {
    grid-column: auto;
  }
  .home-grid > .home-card:last-child {
    grid-column: 1 / -1;
  }
  .home-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .work {
    grid-template-columns: minmax(0, 1fr);
    flex: none;
    min-height: 0;
  }
  .side {
    overflow: visible;
  }
  .side > .table-card {
    flex: none;
  }
  .table-wrap {
    flex: none;
    max-height: 480px;
  }
  .viewer-card {
    min-height: 55vh;
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  /* Brand and actions on the first row, the tabs on their own scrollable row below. */
  .topbar {
    gap: 8px;
    padding: 0 8px;
    height: auto;
    flex-wrap: wrap;
    position: static;
  }
  .topbar .brand {
    height: 48px;
  }
  .topbar .spacer {
    display: block;
  }
  .tabs {
    order: 3;
    flex: 1 0 100%;
    height: 40px;
    overflow-x: auto;
    border-top: 1px solid var(--grid);
    margin: 0 -8px;
    padding: 0 8px;
  }
  .tab {
    padding: 0 10px;
    white-space: nowrap;
  }
  .topbar > .tab,
  .topbar > .icon-button {
    margin: 8px 0;
  }
  .workbench {
    padding: 8px;
  }
  .home {
    padding: 16px 8px 24px;
  }
  .home-grid,
  .home-steps {
    grid-template-columns: minmax(0, 1fr);
  }
  .home-grid > .home-card:last-child {
    grid-column: auto;
  }
  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form {
    grid-template-columns: 1fr;
  }
}

/* ---- Accessibility channels --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Forced colors / high contrast: let the system colors win, keep the pressed state visible. */
@media (forced-colors: active) {
  .chip[aria-pressed='true'],
  .task[aria-pressed='true'] {
    outline: 2px solid Highlight;
  }
  .elements tbody tr[aria-selected='true'] {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
  .tab[aria-current='page'] {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 6px;
  }
  .statusbar-seg {
    forced-color-adjust: none;
  }
}

.field-hint {
  font-size: 11px;
  color: var(--ink-2);
}

/* The record's BIM properties (a collapsible list under the facts). */
.props {
  margin: 2px 0 12px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.props summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.props summary .muted {
  font-weight: 400;
}
.prop-list {
  display: grid;
  grid-template-columns: minmax(0, 11.5rem) minmax(0, 1fr);
  gap: 4px 12px;
  margin: 8px 0 0;
  font-size: 12px;
}
.prop-list dt {
  color: var(--ink-2);
}
.prop-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* The Specture product shell and native operational screens. */
.specture-header {
  flex-shrink: 0;
  min-height: 62px;
  padding: 10px 28px;
}
.account-button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 8px;
  border-radius: 6px;
}
.project-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.project-bar label {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.project-select {
  min-width: 200px;
  max-width: 360px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 9px 30px 9px 12px;
  font-weight: 600;
}
.product-nav {
  display: flex;
  flex-shrink: 0;
  gap: 0 6px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.nav-group {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}
.nav-group[hidden] {
  display: none;
}
.nav-group + .nav-group {
  margin-left: 14px;
}
.nav-group-label {
  padding-right: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.nav-links {
  display: flex;
  gap: 0;
}
.product-nav .tab {
  padding: 12px 9px;
  white-space: nowrap;
  border-radius: 0;
}
.product-nav .tab[hidden] {
  display: none;
}
.product-nav .tab[aria-current='page'] {
  border-bottom: 2px solid var(--accent);
  color: var(--accent-text);
}
/* Wide windows show every group at once and wrap whole groups onto further rows; narrower ones scroll the strip sideways (the current tab is scrolled into view). */
@media (min-width: 1200px) {
  .product-nav {
    flex-wrap: wrap;
    overflow-x: visible;
  }
}
.product-view {
  height: 100%;
  overflow: auto;
}
.product-page {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 28px 60px;
} /* width: inside the column-flex .view an auto-margin item shrinks to its widest table instead of the screen */
.product-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 26px;
}
.product-heading h1 {
  margin: 5px 0 8px;
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.8px;
}
.product-heading p {
  margin: 0;
  max-width: 720px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.product-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.product-actions .button {
  white-space: nowrap;
}
.product-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.product-metrics .tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--surface);
}
.product-metrics .tile-value {
  font-size: 29px;
  margin: 12px 0;
}
.product-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  min-width: 0;
}
.product-card h2 {
  font-size: 16px;
  font-weight: 650;
  margin: 0 0 18px;
}
.product-card .product-actions {
  margin-bottom: 15px;
}
.quick-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-top: 20px;
}
.report-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(60px, 2fr) minmax(30px, auto);
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  font-size: 13px;
}
.report-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.report-track {
  background: var(--grid);
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
}
.report-fill {
  height: 100%;
  min-width: 0;
  background: var(--accent);
  border-radius: 4px;
}
.report-number {
  font-size: 30px;
  letter-spacing: -0.6px;
  margin: 12px 0;
}
.table-scroll {
  overflow: auto;
  max-width: 100%;
  position: relative;
} /* contains the screen-reader-only text of an empty header */
.product-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}
.product-table th {
  padding: 12px 10px;
  border-bottom: 1px solid var(--axis);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-2);
  white-space: nowrap;
}
.product-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.product-table tr:last-child td {
  border-bottom: 0;
}
.product-table .button {
  font-size: 12px;
  padding: 5px 9px;
}
.badge {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--hover);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 12px;
  white-space: nowrap;
}
.empty-state {
  color: var(--ink-2);
  padding: 28px 0;
}
.audit-data {
  white-space: pre-wrap;
  max-width: 420px;
  max-height: 280px;
  overflow: auto;
  font-size: 11px;
}
.product-dialog {
  width: min(660px, calc(100% - 32px));
  max-height: 90vh;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.product-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.session-dialog::backdrop {
  background: var(--page);
}
.product-dialog h2 {
  margin: 0 0 18px;
  font-size: 22px;
  letter-spacing: -0.5px;
}
.product-dialog .product-actions {
  justify-content: flex-end;
  margin-top: 20px;
}
.product-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.product-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
}
.product-field input,
.product-field select,
.product-field textarea {
  background: var(--page);
  border: 1px solid var(--axis);
  border-radius: 6px;
  padding: 10px 12px;
  width: 100%;
  min-height: 42px;
  font-weight: 400;
}
.product-field select[multiple] {
  min-height: 110px;
}
.product-field small {
  font-weight: 400;
}
.product-form-grid .wide {
  grid-column: 1 / -1;
}
.product-field:has(textarea) {
  grid-column: 1 / -1;
}
.form-message[role='alert'] {
  color: var(--danger-ink);
  min-height: 1em;
  white-space: normal;
}
.login-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 30px;
  background: radial-gradient(ellipse at top, var(--accent-wash), transparent 65%), var(--page);
}
.login-card {
  width: min(420px, 100%);
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 26px;
  margin-top: 30px;
  letter-spacing: -0.7px;
}
.login-card .product-field {
  margin-top: 18px;
}
.login-card > .button {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
}
.login-help {
  font-size: 12px;
  margin-top: 24px;
}
.gantt {
  overflow: auto;
}
.gantt-dates {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px 280px;
  min-width: 380px;
  font-size: 12px;
  color: var(--ink-2);
}
.gantt-row {
  display: grid;
  grid-template-columns: 260px minmax(380px, 1fr);
  gap: 20px;
  align-items: center;
  border-top: 1px solid var(--border);
  min-height: 72px;
}
.gantt-label {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 12px 0;
  font-weight: 600;
}
.gantt-label small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-2);
  margin-top: 4px;
}
.gantt-track {
  height: 24px;
  position: relative;
  background: repeating-linear-gradient(to right, var(--grid) 0, var(--grid) 1px, transparent 1px, transparent 10%);
}
.gantt-bar {
  position: absolute;
  height: 20px;
  top: 2px;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: var(--accent-wash);
  overflow: hidden;
  min-width: 5px;
}
.gantt-bar > span {
  display: block;
  background: var(--accent);
  height: 100%;
  opacity: 0.65;
}
.gantt-bar.overdue {
  border-color: var(--danger-ink);
  background: var(--danger-wash);
}
.gantt-bar.milestone {
  width: 14px !important;
  min-width: 14px;
  height: 14px;
  top: 5px;
  transform: translateX(-4px) rotate(45deg);
  border-radius: 0;
  background: var(--accent);
}
.overdue-label {
  color: var(--danger-ink);
  font-weight: 650;
}
.comment {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.comment p {
  margin: 8px 0;
  font-weight: 400;
}
.preserve-lines {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.discussion {
  max-height: 340px;
  overflow: auto;
}
@media (max-width: 1000px) {
  .product-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .product-columns {
    grid-template-columns: 1fr;
    gap: 0;
  }
}
@media (max-width: 600px) {
  .specture-header {
    padding: 10px 14px;
  }
  .account-button {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .project-bar {
    padding: 12px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .project-bar label {
    flex: 1;
  }
  .project-bar .eyebrow {
    display: none;
  }
  .project-select {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .product-nav {
    padding: 0 6px;
  }
  .project-bar > .spacer {
    display: none;
  }
  .product-page {
    padding: 22px 14px 45px;
  }
  .product-heading h1 {
    font-size: 25px;
  }
  .product-card {
    padding: 16px;
  }
  .product-metrics {
    gap: 10px;
  }
  .product-metrics .tile {
    padding: 14px;
  }
  .product-metrics .tile-value {
    font-size: 23px;
  }
  .product-form-grid {
    grid-template-columns: 1fr;
  }
  .product-dialog {
    padding: 20px;
  }
  .report-row {
    gap: 8px;
  }
  .login-card {
    padding: 24px;
  }
  .login-page {
    padding: 16px;
  }
}
.schema-fields {
  display: grid;
  gap: 1rem;
}
.schema-field {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.schema-field legend {
  padding: 0 0.4rem;
  font-weight: 600;
}
.mapping-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}
.mapping-fields h3 {
  grid-column: 1/-1;
}
.platform-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: end;
  margin-bottom: 1rem;
}
.platform-toolbar .product-field {
  min-width: 180px;
  flex: 1;
}
.record-values {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.8rem;
  margin: 0;
}
.record-values dt {
  font-weight: 600;
}
.record-values dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.setup-key {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  user-select: all;
}
.google-sign-in {
  display: block;
  text-align: center;
  margin-top: 0.6rem;
}
.product-card details {
  padding: 0.65rem 0;
}
.product-card summary {
  cursor: pointer;
}
@media (max-width: 600px) {
  .schema-field,
  .mapping-fields {
    grid-template-columns: 1fr;
  }
  .platform-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

.product-card blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#offline-app {
  max-width: 1000px;
  margin: auto;
  overflow: auto;
}
.studio-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.studio-editor,
.studio-widgets {
  display: grid;
  gap: 1rem;
}
.studio-widget,
.studio-mappings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.studio-widget {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.studio-widget legend {
  font-weight: 600;
  padding: 0 0.4rem;
}
.studio-editor[hidden] {
  display: none;
}
.studio-json,
.studio-code {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}
.studio-code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.studio-app-grid {
  display: grid;
  gap: 1rem;
  min-width: 0;
}
.studio-app-grid .product-card {
  min-width: 0;
}
.studio-metric {
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0.6rem 0;
}
.studio-answer {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
}
.studio-nav button {
  white-space: nowrap;
}
@media (max-width: 600px) {
  .studio-widget,
  .studio-mappings {
    grid-template-columns: 1fr;
  }
  .studio-nav {
    gap: 0.35rem;
  }
}
@media print {
  body:has(dialog[open]) > :not(dialog) {
    display: none !important;
  }
  dialog[open] {
    position: static;
    width: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    padding: 0;
  }
  dialog[open] .product-actions,
  dialog[open] button,
  dialog[open] .form-message {
    display: none !important;
  }
  dialog[open] .table-scroll {
    overflow: visible;
  }
}
.product-field[hidden] {
  display: none;
}
