.dash,
.dash * {
  box-sizing: border-box;
}

.dash {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  display: grid;
  grid-template-columns: var(--shell-left-w) minmax(0, 1fr) var(--shell-right-w);
  grid-template-rows: var(--shell-top-h) minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar topbar"
    "left main right";
  background: var(--theme-bg-canvas);
  color: var(--theme-text);
  font-family: var(--theme-font-sans);
  overflow: hidden;
}

.dash__toggle {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  white-space: nowrap;
  clip-path: inset(50%);
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.dash__topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-gap);
  min-height: var(--shell-top-h);
  padding: 0 var(--theme-space-4);
  border-bottom: 1px solid var(--theme-border);
  background: linear-gradient(180deg, var(--theme-surface-2), var(--theme-surface-3));
}

.dash__left,
.dash__right {
  min-height: 0;
  overflow: auto;
  background: linear-gradient(180deg, var(--theme-surface-2), color-mix(in srgb, var(--theme-surface-2) 68%, var(--theme-bg-canvas)));
  padding: var(--theme-space-3);
}

.dash__left {
  grid-area: left;
  border-right: 1px solid var(--theme-border);
}

.dash__right {
  grid-area: right;
  border-left: 1px solid var(--theme-border);
}

.dash__mainWrap {
  grid-area: main;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: linear-gradient(180deg, color-mix(in srgb, var(--theme-surface-1) 76%, transparent), color-mix(in srgb, var(--theme-surface-2) 70%, transparent));
  width: 100%;
  max-width: var(--shell-content-max-w);
  margin-inline: auto;
}

.dash__main {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--theme-space-4);
}

.dash__footer {
  border-top: 1px solid var(--theme-border);
  padding: var(--theme-space-3) var(--theme-space-4);
  color: var(--theme-text-muted);
  background: linear-gradient(180deg, color-mix(in srgb, var(--theme-surface-2) 80%, transparent), color-mix(in srgb, var(--theme-surface-3) 80%, transparent));
}

.dash[data-right-rail="off"] {
  grid-template-columns: var(--shell-left-w) minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "left main";
}

.dash[data-right-rail="off"] .dash__right {
  display: none;
}

.dash[data-collapsed="true"] {
  --shell-left-w: 84px;
}

.dash[data-collapsed="true"] .ui-sidenav__title {
  display: none;
}

.dash[data-collapsed="true"] .ui-sidenav__item {
  justify-content: center;
  padding-inline: var(--theme-space-2);
}


.dash__menuBtn.ui-btn {
  display: none;
  cursor: pointer;
  user-select: none;
}

.dash__railHandle {
  display: none;
  position: fixed;
  top: calc(var(--shell-top-h) + 12px);
  inline-size: 20px;
  block-size: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--theme-border);
  border-right: 0;
  border-radius: var(--theme-radius-md) 0 0 var(--theme-radius-md);
  background: linear-gradient(180deg, var(--theme-surface-2), var(--theme-surface-3));
  color: var(--theme-text-muted);
  cursor: pointer;
  user-select: none;
  z-index: 44;
}

.dash__railHandle:hover {
  color: var(--theme-text);
  border-color: color-mix(in srgb, var(--theme-accent) 52%, var(--theme-border));
}

.dash__railHandle--open {
  right: 0;
}

.dash__railHandle--close {
  right: calc(var(--shell-right-w) - 20px);
}

.dash__backdrop {
  display: none;
}

.ui-topbar,
.ui-topbar__left,
.ui-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--theme-space-2);
}

.ui-topbar__brand {
  color: var(--theme-text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.05em !important;
}

.ui-topbar__spacer {
  flex: 1;
}

.ui-sidenav {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-sidenav__section {
  display: grid;
  /* gap: var(--theme-space-1); */
}

.ui-sidenav__title {
  color: var(--theme-text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--theme-space-1) var(--theme-space-2);
}

.ui-sidenav__item {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* gap: var(--theme-space-1); */
  color: var(--theme-text);
  border: 1px solid transparent;
  border-radius: var(--theme-radius-md);
  text-decoration: none;
  padding: var(--theme-space-1) var(--theme-space-2);
}

.ui-sidenav__item:hover {
  border-color: color-mix(in srgb, var(--theme-accent) 34%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-accent) 12%, transparent);
}

.ui-sidenav__item[data-current="page"] {
  border-color: color-mix(in srgb, var(--theme-accent) 56%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-accent) 20%, transparent);
  font-weight: 600;
}

.ui-sidenav__item[data-active="true"]::after {
  content: "●";
  font-size: 10px;
  color: var(--theme-accent);
}

.ui-pageHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ui-gap);
  margin-bottom: var(--theme-space-4);
}

.ui-pageHeader__title {
  margin: 0;
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
  letter-spacing: 0.01em;
}

.ui-pageHeader__sub {
  margin: var(--theme-space-1) 0 0;
  color: var(--theme-text-muted);
}

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

.ui-span-12 {
  grid-column: span 12;
}

.ui-span-8 {
  grid-column: span 8;
}

.ui-span-6 {
  grid-column: span 6;
}

.ui-span-4 {
  grid-column: span 4;
}

.ui-span-3 {
  grid-column: span 3;
}

.ui-card {
  background: linear-gradient(180deg, var(--theme-surface-1), color-mix(in srgb, var(--theme-surface-2) 82%, var(--theme-surface-1)));
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-lg);
  box-shadow: var(--theme-shadow-md);
  padding: var(--ui-card-pad);
  min-width: 0;
}

.ui-card__title {
  margin: 0;
  font-size: 0.94rem;
  color: var(--theme-text-muted);
}

.ui-card__value {
  margin: var(--theme-space-2) 0 0;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  font-weight: 700;
}

.ui-card__body {
  margin-top: var(--theme-space-3);
}

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--theme-accent) 56%, var(--theme-border));
  border-radius: var(--theme-radius-md);
  background: linear-gradient(180deg, var(--theme-accent-strong), color-mix(in srgb, var(--theme-accent-strong) 86%, black));
  color: var(--theme-accent-contrast);
  font: inherit;
  min-height: var(--ui-control-h);
  padding: 0 var(--theme-space-3);
  cursor: pointer;
}

.ui-btn:hover {
  filter: brightness(1.06);
}

.ui-btn--ghost {
  background: transparent;
  color: var(--theme-text);
  border-color: var(--theme-border);
}

.ui-btn--danger {
  border-color: color-mix(in srgb, #d55656 58%, var(--theme-border));
  background: linear-gradient(180deg, color-mix(in srgb, #d55656 88%, white), color-mix(in srgb, #8b1f1f 84%, black));
  color: #fff6f6;
}

.ui-btn--danger:hover {
  filter: brightness(1.04);
}

.ui-control,
.ui-input,
.ui-select,
.ui-textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: var(--theme-surface-1);
  color: var(--theme-text);
  font: inherit;
}

.ui-input,
.ui-select {
  min-height: var(--ui-control-h);
  height: var(--ui-control-h);
  padding: 0 var(--theme-space-3);
  line-height: 1.2;
}

.ui-textarea {
  min-height: 120px;
  padding: var(--theme-space-3);
  resize: vertical;
}

.ui-input:focus,
.ui-select:focus,
.ui-textarea:focus,
.ui-btn:focus,
.ui-sidenav__item:focus,
.dash__menuBtn:focus {
  outline: none;
  border-color: var(--theme-focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-focus) 30%, transparent);
}

.dash__railHandle:focus {
  outline: none;
  border-color: var(--theme-focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-focus) 30%, transparent);
}

.ui-formRow {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-formRow__label {
  color: var(--theme-text-muted);
  font-size: 0.86rem;
}

.ui-tabs {
  font-size: 0.75rem;
  display: inline-flex;
  gap: 1px;
  padding: var(--theme-space-1);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: color-mix(in srgb, var(--theme-surface-2) 74%, transparent);
}

.ui-tab {
  display: inline-block;
  border: 0;
  border-radius: var(--theme-radius-sm);
  background: transparent;
  color: var(--theme-text-muted);
  text-decoration: none;
  font: inherit;
  line-height: 1.25;
  /* padding: var(--theme-space-1) var(--theme-space-1); */
  cursor: pointer;
}

.ui-tab[data-active="true"] {
  color: var(--theme-text);
  background: color-mix(in srgb, var(--theme-accent) 16%, transparent);
}

.ui-alert {
  margin: var(--theme-space-2) 0;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: var(--theme-space-1);
}

.ui-alert[data-tone="info"] {
  border-color: color-mix(in srgb, var(--theme-accent) 46%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-accent) 10%, transparent);
}

.ui-alert[data-tone="success"] {
  border-color: color-mix(in srgb, var(--theme-success) 55%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-success) 13%, transparent);
}

.ui-alert[data-tone="warning"] {
  border-color: color-mix(in srgb, #d7a94a 62%, var(--theme-border));
  background: color-mix(in srgb, #d7a94a 16%, transparent);
  color: color-mix(in srgb, #d7a94a 84%, var(--theme-text));
}

.ui-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  overflow: hidden;
}

.ui-list__item {
  padding: var(--theme-space-3);
  border-top: 1px solid var(--theme-border);
  background: color-mix(in srgb, var(--theme-surface-1) 88%, transparent);
}

.ui-list__item:first-child {
  border-top: 0;
}

.ui-empty {
  border: 1px dashed color-mix(in srgb, var(--theme-border) 75%, var(--theme-text-muted));
  border-radius: var(--theme-radius-md);
  padding: var(--theme-space-6);
  color: var(--theme-text-muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .ui-span-8,
  .ui-span-6,
  .ui-span-4,
  .ui-span-3 {
    grid-column: span 12;
  }
  .ui-tabs {
    display: none;
  }
}

@media (max-width: 900px) {
  .ui-topbar__right .ui-tabs,
  .ui-topbar__right form .ui-roleTag {
    display: none;
  }

  .dash[data-right-rail="on"] .dash__railHandle--open {
    display: inline-flex;
  }

  .dash[data-right-rail="on"] .dash__railHandle--close {
    right: calc(min(82vw, var(--shell-right-w)) - 20px);
  }

  .dash[data-right-rail="on"]:has(.dash__toggleRight:checked) .dash__railHandle--open {
    display: none;
  }

  .dash[data-right-rail="on"]:has(.dash__toggleRight:checked) .dash__railHandle--close {
    display: inline-flex;
  }

  .dash[data-right-rail="off"] .dash__railHandle {
    display: none;
  }

  .dash {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "main";
  }

  .dash__left,
  .dash__right {
    position: fixed;
    top: var(--shell-top-h);
    bottom: 0;
    width: 75vw;
    max-width: 320px;
    z-index: 42;
    border: 1px solid var(--theme-border);
    box-shadow: var(--theme-shadow-lg);
    transition: transform 180ms ease;
  }

  .dash__left {
    left: 0;
    width: min(82vw, var(--shell-left-w));
    border-left: 0;
    transform: translateX(-103%);
  }

  .dash__right {
    right: 0;
    width: min(82vw, var(--shell-right-w));
    border-right: 0;
    transform: translateX(103%);
  }

  .dash__menuBtn.ui-btn {
    display: inline-flex;
    align-items: center;
  }

  .dash__backdrop {
    display: block;
    position: fixed;
    inset: var(--shell-top-h) 0 0;
    z-index: 36;
    opacity: 0;
    pointer-events: none;
    background: color-mix(in srgb, var(--theme-bg-canvas) 56%, transparent);
    transition: opacity 160ms ease;
  }

  .dash__toggleLeft:checked ~ .dash__left {
    transform: translateX(0);
  }

  .dash__toggleRight:checked ~ .dash__right {
    transform: translateX(0);
  }

  .dash__toggleLeft:checked ~ .dash__backdrop--left,
  .dash__toggleRight:checked ~ .dash__backdrop--right {
    opacity: 1;
    pointer-events: auto;
  }

  .dash__main {
    padding: var(--theme-space-4);
  }

  .dash__footer {
    padding: var(--theme-space-3) var(--theme-space-4);
  }
}

@media (min-width: 901px) {
  .dash__menuBtn.ui-btn {
    display: inline-flex;
  }

  .dash[data-right-rail="on"] {
    grid-template-columns: var(--shell-left-w) minmax(0, 1fr);
    grid-template-areas:
      "topbar topbar"
      "left main";
  }

  .dash[data-right-rail="on"] .dash__right {
    display: none;
  }

  .dash[data-right-rail="on"] .dash__railHandle--open {
    display: inline-flex;
  }

  .dash[data-right-rail="on"] .dash__railHandle--close {
    display: none;
  }

  .dash[data-right-rail="on"]:has(.dash__toggleRight:checked) .dash__railHandle--open {
    display: none;
  }

  .dash[data-right-rail="on"]:has(.dash__toggleRight:checked) .dash__railHandle--close {
    display: inline-flex;
  }

  .dash[data-right-rail="off"] .dash__railHandle {
    display: none;
  }

  .dash:has(.dash__toggleLeft:checked) .dash__left {
    display: none;
  }

  .dash[data-right-rail="on"]:has(.dash__toggleRight:checked) .dash__right {
    display: block;
  }

  .dash[data-right-rail="on"]:has(.dash__toggleLeft:checked) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "main";
  }

  .dash[data-right-rail="on"]:has(.dash__toggleRight:checked) {
    grid-template-columns: var(--shell-left-w) minmax(0, 1fr) var(--shell-right-w);
    grid-template-areas:
      "topbar topbar topbar"
      "left main right";
  }

  .dash[data-right-rail="on"]:has(.dash__toggleLeft:checked):has(.dash__toggleRight:checked) {
    grid-template-columns: minmax(0, 1fr) var(--shell-right-w);
    grid-template-areas:
      "topbar topbar"
      "main right";
  }

  .dash[data-right-rail="off"]:has(.dash__toggleLeft:checked) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "main";
  }
}


/* Table page shell block for VirtualGridTable embeddings */
.ui-tablePanel {
  padding: 0;
  overflow: hidden;
}

.ui-tablePanel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-gap);
  padding: var(--theme-space-3) var(--theme-space-4);
  border-bottom: 1px solid var(--theme-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--theme-surface-2) 80%, transparent), color-mix(in srgb, var(--theme-surface-3) 80%, transparent));
}

.ui-tablePanel__title {
  margin: 0;
  font-size: 0.94rem;
}

.ui-tablePanel__tools {
  display: inline-flex;
  align-items: center;
  gap: var(--theme-space-3);
}

.ui-tablePanel__controls {
  display: inline-flex;
  align-items: center;
  gap: var(--theme-space-2);
}

.ui-tablePanel__controls .ui-formRow__label {
  margin: 0;
  white-space: nowrap;
}

.ui-tablePanel__select {
  width: auto;
  min-width: 220px;
}

.ui-tablePanel__meta {
  color: var(--theme-text-muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.ui-tablePanel__body {
  padding: var(--theme-space-3);
  height: min(68vh, 640px);
}

.ui-tablePanel__body > #grid,
.ui-tablePanel__body > #tableGrid {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.ui-pageBanner {
  display: grid;
  gap: var(--theme-space-2);
  margin-bottom: var(--theme-space-4);
}

.ui-pageBanner .ui-alert {
  margin: 0;
}

/* KPI card primitives */
.ui-kpi {
  display: grid;
  gap: var(--theme-space-1);
}

.ui-kpi__label {
  margin: 0;
  color: var(--theme-text-muted);
  font-size: 0.84rem;
}

.ui-kpi__value {
  margin: 0;
  font-size: clamp(1.1rem, 1.6vw, 1.7rem);
  font-weight: 700;
}

.ui-kpi__trend {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--theme-border);
  font-size: 0.78rem;
  color: var(--theme-text-muted);
}

.ui-kpi__trend[data-tone="success"] {
  border-color: color-mix(in srgb, var(--theme-success) 52%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-success) 14%, transparent);
  color: color-mix(in srgb, var(--theme-success) 85%, var(--theme-text));
}

.ui-kpi__trend[data-tone="danger"] {
  border-color: color-mix(in srgb, #d55656 58%, var(--theme-border));
  background: color-mix(in srgb, #d55656 14%, transparent);
  color: color-mix(in srgb, #d55656 82%, var(--theme-text));
}

.ui-kpi__trend[data-tone="neutral"] {
  border-color: color-mix(in srgb, var(--theme-border) 82%, var(--theme-text-muted));
  background: color-mix(in srgb, var(--theme-surface-2) 70%, transparent);
  color: var(--theme-text-muted);
}

.ui-meterList {
  display: grid;
  gap: var(--theme-space-3);
}

.ui-meterRow {
  display: grid;
  gap: var(--theme-space-1);
}

.ui-meterRow__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--theme-text-muted);
  font-size: 0.84rem;
}

.ui-meter {
  height: 8px;
  border-radius: 999px;
  border: 1px solid var(--theme-border);
  background: color-mix(in srgb, var(--theme-surface-2) 72%, transparent);
  overflow: hidden;
}

.ui-meter__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--theme-accent), color-mix(in srgb, var(--theme-accent) 56%, var(--theme-accent-strong)));
}

.ui-feed {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-feed__item {
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: var(--theme-space-2) var(--theme-space-3);
  background: color-mix(in srgb, var(--theme-surface-1) 88%, transparent);
}

.ui-feed__meta {
  margin: 0;
  font-size: 0.76rem;
  color: var(--theme-text-muted);
}

.ui-feed__text {
  margin: var(--theme-space-1) 0 0;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .ui-tablePanel__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .ui-tablePanel__tools {
    width: 100%;
    justify-content: space-between;
  }

  .ui-tablePanel__controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .ui-tablePanel__select {
    min-width: 0;
    width: 100%;
  }

  .ui-tablePanel__meta {
    white-space: normal;
  }

  .ui-tablePanel__body {
    height: min(60vh, 520px);
    padding: var(--theme-space-2);
  }
}

/* Items page primitives */
.ui-itemPanel {
  padding: 0;
  overflow: hidden;
}

.ui-machineList {
  display: grid;
  gap: var(--theme-space-3);
  padding: var(--theme-space-3);
}

.ui-machineCard {
  display: grid;
  gap: var(--theme-space-3);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: color-mix(in srgb, var(--theme-surface-1) 92%, transparent);
  padding: var(--theme-space-3);
}

.ui-machineCard[data-tone="danger"] {
  border-color: color-mix(in srgb, #d55656 40%, var(--theme-border));
}

.ui-machineCard[data-tone="success"] {
  border-color: color-mix(in srgb, var(--theme-accent) 42%, var(--theme-border));
}

.ui-machineHeader {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--theme-space-3);
}

.ui-machineMetaGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--theme-space-2);
}

.ui-machineMeta {
  display: grid;
  gap: 4px;
  padding: var(--theme-space-2);
  border-radius: var(--theme-radius-sm);
  background: color-mix(in srgb, var(--theme-surface-2) 74%, transparent);
}

.ui-machineMeta__label {
  font-size: 0.76rem;
  color: var(--theme-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ui-machineForm {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--theme-space-3);
  align-items: start;
}

.ui-machineForm > .ui-machineActions {
  grid-column: 1 / -1;
}

.ui-domainReferencePanel {
  display: grid;
  gap: var(--theme-space-2);
  margin-top: var(--theme-space-2);
  padding: var(--theme-space-2);
  border: 1px solid color-mix(in srgb, var(--theme-accent) 30%, var(--theme-border));
  border-radius: var(--theme-radius-sm);
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--theme-accent) 14%, transparent), transparent 48%),
    linear-gradient(180deg, color-mix(in srgb, var(--theme-surface-2) 88%, transparent), color-mix(in srgb, var(--theme-surface-1) 94%, transparent));
}

.ui-domainReferencePanel__head,
.ui-domainReferencePanel__list,
.ui-domainReferenceCard {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-domainReferenceCard {
  padding: var(--theme-space-2);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-sm);
  background: color-mix(in srgb, var(--theme-surface-1) 92%, transparent);
}

.ui-domainReferenceCard__copy {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--theme-space-2);
}

.ui-domainReferenceCard__title {
  margin: 0;
  font-size: 0.94rem;
}

.ui-domainReferenceCard__action {
  min-width: 88px;
  white-space: nowrap;
}

.ui-domainReferenceCard__value {
  display: block;
  padding: var(--theme-space-2);
  border-radius: var(--theme-radius-sm);
  background: color-mix(in srgb, var(--theme-surface-3) 62%, transparent);
  color: var(--theme-text);
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.ui-machineActions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--theme-space-2);
  align-items: center;
}

.ui-machineDownloadPanel {
  display: grid;
  gap: var(--theme-space-3);
  border: 1px solid color-mix(in srgb, var(--theme-accent) 56%, var(--theme-border));
  border-radius: var(--theme-radius-md);
  padding: var(--theme-space-3);
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--theme-accent) 22%, transparent), transparent 42%),
    linear-gradient(135deg, color-mix(in srgb, var(--theme-accent) 12%, transparent), color-mix(in srgb, var(--theme-surface-1) 94%, transparent));
  box-shadow: inset 0 1px 0 color-mix(in srgb, #ffffff 10%, transparent);
}

.ui-machineDownloadPanel[data-tone="blocked"] {
  border-color: color-mix(in srgb, var(--theme-border) 82%, var(--theme-text-muted));
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--theme-surface-3) 72%, transparent), transparent 42%),
    linear-gradient(135deg, color-mix(in srgb, var(--theme-surface-2) 76%, transparent), color-mix(in srgb, var(--theme-surface-1) 94%, transparent));
}

.ui-machineDownloadPanel__head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--theme-space-3);
}

.ui-machineDownloadPanel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--theme-space-2);
  align-items: center;
}

.ui-machineDownloadPanel__note {
  width: 100%;
}

.ui-btn--bundle {
  min-width: 188px;
  font-weight: 700;
  border-color: color-mix(in srgb, var(--theme-accent) 70%, var(--theme-border));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--theme-accent) 22%, transparent);
}

.ui-btn--bundleAlt {
  border-color: color-mix(in srgb, var(--theme-success) 62%, var(--theme-border));
  background: linear-gradient(180deg, var(--theme-success), color-mix(in srgb, var(--theme-success) 84%, black));
  color: var(--theme-accent-contrast);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--theme-success) 22%, transparent);
}

.ui-queryEditorPanel {
  display: grid;
  gap: var(--theme-space-3);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: color-mix(in srgb, var(--theme-surface-1) 90%, transparent);
  overflow: hidden;
}

.ui-queryPresetList {
  display: grid;
  gap: var(--theme-space-3);
  padding: var(--theme-space-3);
}

.ui-queryPresetCard {
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: color-mix(in srgb, var(--theme-surface-2) 72%, transparent);
  padding: var(--theme-space-3);
}

.ui-queryEditor {
  display: grid;
  gap: var(--theme-space-3);
}

.ui-queryEditor__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--theme-space-3);
}

.ui-queryEditor__tools {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: var(--theme-space-2);
  align-items: end;
}

.ui-queryEditor__loadSelect {
  min-width: 0;
}

.ui-queryList {
  display: grid;
  gap: var(--theme-space-3);
}

.ui-queryListWrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-sm);
  background: color-mix(in srgb, var(--theme-surface-1) 74%, transparent);
}

.ui-queryList--compact {
  padding: var(--theme-space-2);
  gap: var(--theme-space-2);
}

.ui-queryCompactRow {
  display: grid;
  gap: var(--theme-space-2);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-sm);
  padding: var(--theme-space-2);
  background: color-mix(in srgb, var(--theme-surface-1) 86%, transparent);
}

.ui-queryCompactRow[data-pending-remove="true"] {
  border-color: color-mix(in srgb, #d55656 58%, var(--theme-border));
  background: color-mix(in srgb, #d55656 10%, transparent);
  opacity: 0.78;
}

.ui-queryCompactRow__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--theme-space-2);
}

.ui-queryCompactRow__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--theme-space-2);
}

.ui-queryCompactRow__sqlMeta {
  display: grid;
  gap: 2px;
}

.ui-queryModal {
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: 0;
  margin: auto;
  width: min(1320px, 94vw);
  max-width: 1320px;
  background: color-mix(in srgb, var(--theme-surface-1) 94%, var(--theme-surface-2));
  color: var(--theme-text);
}

.ui-queryModal::backdrop {
  background: color-mix(in srgb, #101118 62%, transparent);
}

.ui-queryModal__content {
  display: grid;
  gap: var(--theme-space-3);
  padding: var(--theme-space-3);
}

.ui-queryModal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--theme-space-2);
}

.ui-queryModal__metaGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--theme-space-2);
}

.ui-queryModal__editorGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--theme-space-3);
}

.ui-queryModal__editorPane {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-deleteMachinePanel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--theme-space-3);
  padding: var(--theme-space-3);
  border: 1px solid color-mix(in srgb, #d55656 34%, var(--theme-border));
  border-radius: var(--theme-radius-md);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, #d55656 14%, transparent), transparent 48%),
    linear-gradient(180deg, color-mix(in srgb, var(--theme-surface-2) 88%, transparent), color-mix(in srgb, var(--theme-surface-3) 86%, transparent));
}

.ui-deleteMachinePanel__copy {
  display: grid;
  gap: var(--theme-space-2);
  flex: 1 1 auto;
}

.ui-deleteMachineModal {
  width: min(640px, 92vw);
  max-width: 640px;
}

.ui-deleteMachineModal__content,
.ui-deleteMachineModal__form {
  display: grid;
  gap: var(--theme-space-3);
}

.ui-sqlConsole {
  display: grid;
  gap: var(--theme-space-4);
}

.ui-sqlConsole__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ui-gap);
}

.ui-sqlConsole__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--theme-space-2);
}

.ui-sqlConsole__statusRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--theme-space-2);
}

.ui-sqlConsole__status {
  display: inline-flex;
  align-items: center;
  gap: var(--theme-space-2);
  min-height: 34px;
  padding: 0 var(--theme-space-3);
  border: 1px solid var(--theme-border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--theme-surface-2) 78%, transparent);
  color: var(--theme-text-muted);
  font-size: 0.84rem;
}

.ui-sqlConsole__status[data-tone="success"] {
  border-color: color-mix(in srgb, var(--theme-success) 52%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-success) 14%, transparent);
  color: color-mix(in srgb, var(--theme-success) 82%, var(--theme-text));
}

.ui-sqlConsole__status[data-tone="danger"] {
  border-color: color-mix(in srgb, #d55656 56%, var(--theme-border));
  background: color-mix(in srgb, #d55656 14%, transparent);
  color: color-mix(in srgb, #d55656 84%, var(--theme-text));
}

.ui-sqlConsole__layout {
  display: grid;
  grid-template-rows: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: var(--theme-space-4);
  min-height: 0;
}

.ui-sqlConsole__panel,
.ui-managedViewsPanel {
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: color-mix(in srgb, var(--theme-surface-1) 92%, transparent);
  overflow: hidden;
}

.ui-sqlConsole__panelHead,
.ui-managedViewsPanel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--theme-space-3);
  padding: var(--theme-space-3) var(--theme-space-4);
  border-bottom: 1px solid var(--theme-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--theme-surface-2) 80%, transparent), color-mix(in srgb, var(--theme-surface-3) 82%, transparent));
}

.ui-sqlConsole__panelBody,
.ui-managedViewsPanel__body {
  padding: var(--theme-space-3);
}

.ui-sqlConsole__editorPane {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-sqlConsole__resultPane {
  display: grid;
  gap: var(--theme-space-2);
  min-height: 0;
}

.ui-sqlConsole__resultGrid {
  min-height: 320px;
  height: min(42vh, 520px);
}

.ui-sqlConsole__resultMeta,
.ui-managedViewsPanel__meta {
  color: var(--theme-text-muted);
  font-size: 0.84rem;
}

.ui-sqlModal,
.ui-sqlLoadModal {
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: 0;
  margin: auto;
  width: min(1080px, 94vw);
  background: color-mix(in srgb, var(--theme-surface-1) 94%, var(--theme-surface-2));
  color: var(--theme-text);
}

.ui-sqlModal::backdrop,
.ui-sqlLoadModal::backdrop {
  background: color-mix(in srgb, #101118 62%, transparent);
}

.ui-sqlModal__content,
.ui-sqlLoadModal__content {
  display: grid;
  gap: var(--theme-space-3);
  padding: var(--theme-space-3);
}

.ui-sqlLoadModal__list {
  display: grid;
  gap: var(--theme-space-2);
  max-height: min(52vh, 620px);
  overflow: auto;
}

.ui-sqlLoadModal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--theme-space-2);
}

.ui-managedViewsPanel__layout {
  display: grid;
  gap: var(--theme-space-3);
}

.ui-managedViewsPanel__grid {
  display: grid;
  gap: var(--theme-space-3);
}

.ui-managedViewsPanel__grid--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ui-managedViewsPanel__section {
  display: grid;
  gap: var(--theme-space-2);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-sm);
  padding: var(--theme-space-3);
  background: color-mix(in srgb, var(--theme-surface-2) 72%, transparent);
}

.ui-managedViewsPanel__section--full {
  grid-column: 1 / -1;
}

.ui-managedViewsPanel__sectionTitle {
  margin: 0;
  font-size: 0.94rem;
}

.ui-managedViewsPanel__controls {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-managedViewsPanel__controlsRow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--theme-space-2);
}

.ui-managedViewsPanel__controlsRow--dense {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ui-managedViewsPanel__formRow--span2 {
  grid-column: span 2;
}

.ui-managedViewsPanel__formRow--span3 {
  grid-column: span 3;
}

.ui-managedViewsPanel__preview {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-managedViewsPanel__previewGrid {
  min-height: 280px;
  height: min(34vh, 420px);
}

.ui-managedViewsPanel__grantList {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-managedViewsPanel__grantRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--theme-space-2);
  align-items: center;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-sm);
  padding: var(--theme-space-2) var(--theme-space-3);
  background: color-mix(in srgb, var(--theme-surface-1) 90%, transparent);
}

.ui-managedViewsPanel__grantMeta {
  display: grid;
  gap: 2px;
}

.ui-managedViewsPanel__grantActions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--theme-space-2);
  align-items: center;
}

.ui-queryCompactRow[data-current="true"] {
  border-color: color-mix(in srgb, var(--theme-accent) 58%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-accent) 12%, transparent);
}

.ui-managedViewsPanel__saveBar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--theme-space-2);
}

.ui-managedViewsPanel__groupLayout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  gap: var(--theme-space-3);
}

.ui-managedViewsPanel__textarea {
  min-height: 152px;
}

.ui-managedViewsHelp {
  max-width: min(920px, 94vw);
}

.ui-managedViewsHelp__section {
  display: grid;
  gap: var(--theme-space-2);
}

.ui-managedViewsHelp__list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.45rem;
  color: var(--theme-text-muted);
}

.ui-sqlEditor {
  position: relative;
  min-height: min(64vh, 620px);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-sm);
  overflow: hidden;
  background: color-mix(in srgb, var(--theme-surface-2) 60%, #0d1117);
}

.ui-sqlEditor__highlight,
.ui-sqlEditor__input {
  margin: 0;
  position: absolute;
  inset: 0;
  padding: var(--theme-space-3);
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}

.ui-sqlEditor__highlight {
  pointer-events: none;
  color: color-mix(in srgb, var(--theme-text) 82%, transparent);
  opacity: 0;
}

.ui-sqlEditor__input {
  border: 0;
  resize: none;
  outline: 0;
  background: transparent;
  color: var(--theme-text);
  caret-color: var(--theme-text);
}

.ui-sqlEditor[data-sql-editor-ready="true"] .ui-sqlEditor__highlight {
  opacity: 1;
}

.ui-sqlEditor[data-sql-editor-ready="true"] .ui-sqlEditor__input {
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.ui-sqlEditor__keyword {
  color: color-mix(in srgb, var(--theme-accent) 82%, #ffffff);
  font-weight: 600;
}

.ui-sqlEditor__comment {
  color: color-mix(in srgb, #88a38d 70%, var(--theme-text-muted));
}

.ui-sqlEditor__string {
  color: color-mix(in srgb, #d4c07c 84%, var(--theme-text));
}

.ui-sqlEditor__input::selection {
  background: color-mix(in srgb, var(--theme-accent) 28%, transparent);
}

.ui-sqlEditor--compact {
  min-height: min(36vh, 360px);
}

.ui-sqlEditor--compact .ui-sqlEditor__highlight,
.ui-sqlEditor--compact .ui-sqlEditor__input {
  font-size: 0.8rem;
}

.ui-sqlEditor--dense {
  min-height: min(28vh, 280px);
}

.ui-itemList {
  max-height: min(68vh, 760px);
  overflow: auto;
  display: grid;
  gap: var(--theme-space-2);
  padding: var(--theme-space-3);
}

.ui-itemRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--theme-space-3);
  align-items: center;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: color-mix(in srgb, var(--theme-surface-1) 90%, transparent);
  padding: var(--theme-space-3);
}

.ui-itemInfo {
  min-width: 0;
}

.ui-itemTitle {
  margin: 0;
  font-size: 0.96rem;
}

.ui-itemMeta {
  margin: var(--theme-space-1) 0 0;
  color: var(--theme-text-muted);
  font-size: 0.82rem;
}

.ui-itemActions {
  display: inline-flex;
  align-items: center;
  gap: var(--theme-space-2);
}

.ui-itemActions form {
  margin: 0;
}

.ui-itemBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-sm);
  min-height: 32px;
  padding: 0 var(--theme-space-3);
  background: color-mix(in srgb, var(--theme-surface-2) 78%, transparent);
  color: var(--theme-text);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.ui-itemBtn:hover {
  border-color: color-mix(in srgb, var(--theme-accent) 46%, var(--theme-border));
  background: color-mix(in srgb, var(--theme-accent) 12%, transparent);
}

.ui-itemBtn--danger {
  border-color: color-mix(in srgb, #d55656 56%, var(--theme-border));
  background: color-mix(in srgb, #d55656 13%, transparent);
  color: color-mix(in srgb, #d55656 85%, var(--theme-text));
}

.ui-roleTag {
  border: 1px solid var(--theme-border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.78rem;
  color: var(--theme-text-muted);
  background: color-mix(in srgb, var(--theme-surface-2) 72%, transparent);
}

.dash:not([data-user-role="admin"]) .ui-itemBtn--danger {
  display: none;
}

@media (max-width: 900px) {
  .ui-sqlConsole__head,
  .ui-managedViewsPanel__head,
  .ui-sqlConsole__statusRow {
    flex-direction: column;
    align-items: flex-start;
  }

  .ui-sqlConsole__toolbar,
  .ui-managedViewsPanel__saveBar {
    width: 100%;
    justify-content: flex-start;
  }

  .ui-sqlConsole__layout {
    grid-template-rows: auto auto;
  }

  .ui-sqlConsole__resultGrid,
  .ui-managedViewsPanel__previewGrid {
    height: min(34vh, 360px);
    min-height: 240px;
  }

  .ui-managedViewsPanel__grid--compact,
  .ui-managedViewsPanel__groupLayout,
  .ui-managedViewsPanel__controlsRow,
  .ui-managedViewsPanel__controlsRow--dense {
    grid-template-columns: 1fr;
  }

  .ui-managedViewsPanel__formRow--span2,
  .ui-managedViewsPanel__formRow--span3 {
    grid-column: auto;
  }

  .ui-machineMetaGrid,
  .ui-machineForm {
    grid-template-columns: 1fr;
  }

  .ui-queryEditor__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ui-queryEditor__tools {
    grid-template-columns: 1fr;
  }

  .ui-queryModal {
    width: 96vw;
  }

  .ui-queryModal__metaGrid,
  .ui-queryModal__editorGrid {
    grid-template-columns: 1fr;
  }

  .ui-deleteMachinePanel {
    flex-direction: column;
    align-items: stretch;
  }

  .ui-domainReferenceCard__copy {
    flex-direction: column;
    align-items: stretch;
  }

  .ui-sqlEditor {
    min-height: min(52vh, 520px);
  }

  .ui-machineHeader {
    flex-direction: column;
    align-items: start;
  }

  .ui-machineDownloadPanel__head {
    flex-direction: column;
    align-items: start;
  }

  .ui-itemRow {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .ui-itemActions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Design refresh: shared shell and component overrides */
.dash {
  background: var(--color-bg-canvas);
  color: var(--color-text-primary);
}

.dash__topbar {
  min-height: var(--shell-top-h);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
  background: color-mix(in srgb, var(--color-surface-base) 92%, var(--color-bg-subtle));
  backdrop-filter: blur(16px);
}

.dash__left,
.dash__right {
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-bg-subtle) 74%, var(--color-surface-base));
}

.dash__left {
  border-right: 1px solid var(--color-border-subtle);
}

.dash__right {
  border-left: 1px solid var(--color-border-subtle);
}

.dash__mainWrap {
  background: transparent;
}

.dash__main {
  padding: var(--space-6);
}

.dash__footer {
  border-top: 1px solid var(--color-border-subtle);
  padding: var(--space-4) var(--space-6);
  color: var(--color-text-secondary);
  background: color-mix(in srgb, var(--color-surface-base) 88%, var(--color-bg-subtle));
}

.dash__railHandle {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  background: var(--color-surface-base);
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-sm);
}

.dash__railHandle:hover {
  color: var(--color-text-primary);
  border-color: color-mix(in srgb, var(--color-accent-primary) 30%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-accent-primary-soft) 48%, var(--color-surface-base));
}

.dash__backdrop {
  backdrop-filter: blur(4px);
}

.ui-topbar,
.ui-topbar__left,
.ui-topbar__right,
.ui-topbar__user {
  gap: var(--space-2);
  align-items: center;
  align-content: center;
  justify-items: center;;
}

.ui-topbar__user {
  display: inline-flex;
  margin: 0;
  height: var(--control-height-md);
  align-self: center;
}

.ui-topbar__theme,
.ui-topbar__user {
  align-items: center;
}

.ui-topbar__brand {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ui-topbar__brand:hover {
  color: var(--color-text-primary);
}

.ui-topbar__theme {
  flex: 0 0 7rem;
  min-width: 7rem;
  display: inline-flex;
}

.ui-topbar__themeSelect {
  width: 100%;
  height: var(--control-height-md);
  min-height: var(--control-height-md);
  line-height: 1;
}

.ui-topbar__user .ui-btn {
  height: var(--control-height-md);
  min-height: var(--control-height-md);
  line-height: 1;
}

.ui-sidenav {
  gap: var(--space-5);
}

.ui-sidenav__title {
  color: var(--color-text-tertiary);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ui-sidenav__item {
  position: relative;
  justify-content: flex-start;
  min-height: 40px;
  padding: 10px 12px 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition:
    background-color var(--motion-base) var(--motion-ease),
    color var(--motion-base) var(--motion-ease),
    border-color var(--motion-base) var(--motion-ease),
    box-shadow var(--motion-base) var(--motion-ease);
}

.ui-sidenav__item:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--color-surface-hover) 84%, transparent);
  color: var(--color-text-primary);
}

.ui-sidenav__item[data-current="page"] {
  border-color: color-mix(in srgb, var(--color-accent-primary) 22%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-accent-primary-soft) 72%, var(--color-surface-base));
  color: var(--color-text-primary);
  box-shadow: inset 2px 0 0 var(--color-accent-primary);
}

.ui-sidenav__item[data-active="true"]::after {
  content: "";
  inline-size: 6px;
  block-size: 6px;
  margin-inline-start: auto;
  border-radius: 999px;
  background: var(--color-accent-cyan);
}

.ui-pageHeader {
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.ui-pageHeader__copy {
  display: grid;
  gap: var(--space-1);
  max-width: 72ch;
}

.ui-pageHeader__title {
  color: var(--color-text-primary);
  font-size: clamp(1.5rem, 1.16rem + 0.88vw, 1.75rem);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.ui-pageHeader__sub {
  margin-top: 0;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.ui-pageHeader__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.ui-grid {
  gap: var(--space-5);
}

.ui-card {
  background: var(--color-surface-base);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--ui-card-pad);
}

.ui-card__title {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
}

.ui-card__value {
  color: var(--color-text-primary);
  font-weight: 600;
  line-height: 1.1;
}

.ui-btn,
.ui-input,
.ui-select,
.ui-textarea {
  border-radius: var(--control-radius);
}

.ui-btn {
  min-height: var(--control-height-md);
  padding: 0 15px;
  border: 1px solid color-mix(in srgb, var(--color-accent-primary-hover) 42%, var(--color-accent-primary));
  background: var(--color-accent-primary);
  color: var(--theme-accent-contrast);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-xs);
  transition:
    background-color var(--motion-fast) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease),
    color var(--motion-fast) var(--motion-ease);
}

.ui-btn:hover {
  filter: none;
  background: var(--color-accent-primary-hover);
  border-color: color-mix(in srgb, var(--color-accent-primary-hover) 72%, var(--color-accent-primary));
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.ui-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
  background: color-mix(in srgb, var(--color-accent-primary-hover) 92%, black);
}

.ui-btn:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ui-btn--ghost {
  border-color: var(--color-border-subtle);
  background: color-mix(in srgb, var(--color-surface-hover) 90%, transparent);
  color: var(--color-text-primary);
  box-shadow: none;
}

.ui-btn--ghost:hover {
  background: color-mix(in srgb, var(--color-accent-primary-soft) 48%, var(--color-surface-hover));
  border-color: color-mix(in srgb, var(--color-accent-primary) 24%, var(--color-border-subtle));
  box-shadow: none;
}

.ui-btn--danger {
  border-color: color-mix(in srgb, var(--color-danger) 42%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-danger) 14%, var(--color-surface-base));
  color: color-mix(in srgb, var(--color-danger) 82%, var(--color-text-primary));
  box-shadow: none;
}

.ui-btn--danger:hover {
  background: color-mix(in srgb, var(--color-danger) 20%, var(--color-surface-base));
}

.ui-btn--bundle {
  border-color: color-mix(in srgb, var(--color-accent-primary) 36%, var(--color-border-subtle));
  box-shadow: var(--shadow-sm);
}

.ui-btn--bundleAlt {
  border-color: color-mix(in srgb, var(--color-success) 38%, var(--color-border-subtle));
  background: var(--color-success);
  color: var(--theme-accent-contrast);
  box-shadow: var(--shadow-sm);
}

.ui-control,
.ui-input,
.ui-select,
.ui-textarea {
  border-color: var(--color-border-subtle);
  background: var(--color-surface-base);
  color: var(--color-text-primary);
  transition:
    border-color var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease),
    background-color var(--motion-fast) var(--motion-ease);
}

.ui-input,
.ui-select {
  min-height: var(--ui-control-h);
  height: var(--ui-control-h);
  padding: 0 13px;
}

.ui-textarea {
  min-height: 96px;
  padding: 12px 14px;
  line-height: 1.5;
}

.ui-input::placeholder,
.ui-textarea::placeholder {
  color: var(--color-text-tertiary);
}

.ui-input:disabled,
.ui-select:disabled,
.ui-textarea:disabled {
  background: color-mix(in srgb, var(--color-surface-hover) 90%, transparent);
  color: var(--color-text-disabled);
}

.ui-formRow {
  gap: var(--space-2);
}

.ui-formRow__label {
  color: var(--color-text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
}

.ui-tabs {
  gap: 0;
  padding: 4px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--control-radius);
  background: color-mix(in srgb, var(--color-bg-subtle) 76%, transparent);
}

.ui-tab {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: calc(var(--control-radius) - 2px);
  color: var(--color-text-secondary);
  transition:
    background-color var(--motion-fast) var(--motion-ease),
    color var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease);
}

.ui-tab:hover {
  color: var(--color-text-primary);
  background: color-mix(in srgb, var(--color-surface-hover) 78%, transparent);
}

.ui-tab[data-active="true"] {
  color: var(--color-text-primary);
  background: var(--color-surface-base);
  box-shadow: var(--shadow-xs);
}

.ui-alert {
  display: grid;
  gap: var(--space-1);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: color-mix(in srgb, var(--color-bg-subtle) 72%, var(--color-surface-base));
  color: var(--color-text-secondary);
}

.ui-alert[data-tone="info"] {
  border-color: color-mix(in srgb, var(--color-info) 24%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-info) 9%, var(--color-surface-base));
  color: color-mix(in srgb, var(--color-info) 22%, var(--color-text-primary));
}

.ui-alert[data-tone="success"] {
  border-color: color-mix(in srgb, var(--color-success) 24%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-success) 10%, var(--color-surface-base));
  color: color-mix(in srgb, var(--color-success) 24%, var(--color-text-primary));
}

.ui-alert[data-tone="warning"] {
  border-color: color-mix(in srgb, var(--color-warning) 26%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-warning) 11%, var(--color-surface-base));
  color: color-mix(in srgb, var(--color-warning) 28%, var(--color-text-primary));
}

.ui-alert[data-tone="danger"] {
  border-color: color-mix(in srgb, var(--color-danger) 26%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-danger) 10%, var(--color-surface-base));
  color: color-mix(in srgb, var(--color-danger) 24%, var(--color-text-primary));
}

.ui-list {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-bg-subtle) 44%, var(--color-surface-base));
}

.ui-list__item {
  padding: 14px 16px;
  border-top-color: var(--color-border-subtle);
  background: transparent;
}

.ui-empty {
  border: 1px dashed var(--color-border-default);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  background: color-mix(in srgb, var(--color-bg-subtle) 54%, var(--color-surface-base));
  color: var(--color-text-secondary);
}

.ui-tablePanel {
  background: var(--color-surface-base);
}

.ui-tablePanel__head {
  gap: var(--space-4);
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
  background: color-mix(in srgb, var(--color-surface-base) 90%, var(--color-bg-subtle));
}

.ui-tablePanel__title {
  color: var(--color-text-primary);
  font-size: 1rem;
  font-weight: 600;
}

.ui-tablePanel__tools {
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.ui-tablePanel__controls {
  min-width: 220px;
}

.ui-tablePanel__status {
  display: flex;
  align-items: center;
  min-height: var(--ui-control-h);
}

.ui-tablePanel__meta {
  color: var(--color-text-secondary);
  font-size: 0.82rem;
  line-height: 1.5;
}

.ui-tablePanel__body {
  padding: var(--space-5);
  background: color-mix(in srgb, var(--color-bg-subtle) 34%, transparent);
}

.ui-kpi {
  gap: var(--space-2);
}

.ui-kpi__label {
  color: var(--color-text-secondary);
  font-size: 0.78rem;
}

.ui-kpi__value {
  font-size: clamp(1.35rem, 1.05rem + 1.1vw, 1.8rem);
  letter-spacing: -0.03em;
}

.ui-kpi__trend {
  min-height: 28px;
  padding: 0 10px;
  border-color: var(--color-border-subtle);
  background: color-mix(in srgb, var(--color-bg-subtle) 72%, transparent);
}

.ui-meterRow__head {
  color: var(--color-text-secondary);
  font-size: 0.82rem;
}

.ui-meter {
  border: 0;
  background: color-mix(in srgb, var(--color-bg-subtle) 88%, transparent);
}

.ui-meter__bar {
  background: color-mix(in srgb, var(--color-accent-primary) 86%, white);
}

.ui-feed__item,
.ui-queryPresetCard,
.ui-queryCompactRow,
.ui-managedViewsPanel__grantRow,
.ui-itemRow,
.ui-machineCard {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-surface-hover) 54%, var(--color-surface-base));
}

.ui-feed__item,
.ui-queryPresetCard,
.ui-itemRow {
  padding: 14px 16px;
}

.ui-feed__meta,
.ui-itemMeta {
  color: var(--color-text-secondary);
}

.ui-feed__text,
.ui-itemTitle {
  color: var(--color-text-primary);
}

.ui-queryListWrap,
.ui-queryEditorPanel {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-bg-subtle) 48%, var(--color-surface-base));
}

.ui-queryCompactRow[data-current="true"] {
  border-color: color-mix(in srgb, var(--color-accent-primary) 26%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-accent-primary-soft) 54%, var(--color-surface-base));
}

.ui-queryCompactRow[data-pending-remove="true"] {
  border-color: color-mix(in srgb, var(--color-danger) 32%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-danger) 10%, var(--color-surface-base));
}

.ui-queryModal,
.ui-sqlModal,
.ui-sqlLoadModal {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-xl);
  background: var(--color-surface-elevated);
  box-shadow: var(--shadow-lg);
}

.ui-queryModal::backdrop,
.ui-sqlModal::backdrop,
.ui-sqlLoadModal::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
}

.ui-queryModal__content,
.ui-sqlModal__content,
.ui-sqlLoadModal__content {
  gap: var(--space-4);
  padding: var(--space-5);
}

.ui-deleteMachinePanel {
  border-color: color-mix(in srgb, var(--color-danger) 28%, var(--color-border-subtle));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-danger) 8%, var(--color-surface-base));
}

.ui-sqlConsole__status {
  min-height: 32px;
  border-color: var(--color-border-subtle);
  background: color-mix(in srgb, var(--color-bg-subtle) 76%, var(--color-surface-base));
  color: var(--color-text-secondary);
}

.ui-sqlConsole__status[data-tone="success"] {
  border-color: color-mix(in srgb, var(--color-success) 24%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-success) 10%, var(--color-surface-base));
  color: color-mix(in srgb, var(--color-success) 26%, var(--color-text-primary));
}

.ui-sqlConsole__status[data-tone="danger"] {
  border-color: color-mix(in srgb, var(--color-danger) 24%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-danger) 10%, var(--color-surface-base));
  color: color-mix(in srgb, var(--color-danger) 24%, var(--color-text-primary));
}

.ui-sqlConsole__panel,
.ui-managedViewsPanel {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-lg);
  background: var(--color-surface-base);
  box-shadow: var(--shadow-xs);
}

.ui-sqlConsole__panelHead,
.ui-managedViewsPanel__head {
  align-items: center;
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
  background: color-mix(in srgb, var(--color-bg-subtle) 60%, var(--color-surface-base));
}

.ui-sqlConsole__panelBody,
.ui-managedViewsPanel__body {
  padding: var(--space-5);
}

.ui-managedViewsPanel__section {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: color-mix(in srgb, var(--color-bg-subtle) 40%, var(--color-surface-base));
}

.ui-managedViewsPanel__saveBar,
.ui-machineActions,
.ui-queryCompactRow__actions,
.ui-queryEditor__tools,
.ui-queryModal__header,
.ui-machineDownloadPanel__actions {
  gap: var(--space-2);
}

.ui-sqlEditor {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-bg-subtle) 80%, var(--color-surface-base));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--color-text-primary) 5%, transparent);
}

.ui-sqlEditor__highlight,
.ui-sqlEditor__input {
  font-family: var(--font-mono);
}

.ui-sqlEditor__keyword {
  color: color-mix(in srgb, var(--color-accent-primary) 84%, var(--color-accent-cyan));
}

.ui-sqlEditor__comment {
  color: color-mix(in srgb, var(--color-success) 52%, var(--color-text-secondary));
}

.ui-sqlEditor__string {
  color: color-mix(in srgb, var(--color-warning) 82%, var(--color-text-primary));
}

.ui-itemBtn {
  border-color: var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-surface-hover) 82%, transparent);
  color: var(--color-text-primary);
}

.ui-itemBtn:hover {
  border-color: color-mix(in srgb, var(--color-accent-primary) 22%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-accent-primary-soft) 48%, var(--color-surface-hover));
}

.ui-itemBtn--danger {
  border-color: color-mix(in srgb, var(--color-danger) 24%, var(--color-border-subtle));
  background: color-mix(in srgb, var(--color-danger) 10%, var(--color-surface-base));
  color: color-mix(in srgb, var(--color-danger) 24%, var(--color-text-primary));
}

.ui-roleTag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-color: var(--color-border-subtle);
  background: color-mix(in srgb, var(--color-bg-subtle) 76%, transparent);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.ui-machineMeta {
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-bg-subtle) 78%, transparent);
}

.ui-machineMeta__label {
  color: var(--color-text-tertiary);
}

.ui-machineDownloadPanel {
  border-color: color-mix(in srgb, var(--color-accent-primary) 22%, var(--color-border-subtle));
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-accent-primary-soft) 24%, var(--color-surface-base));
  box-shadow: var(--shadow-xs);
}

.ui-machineDownloadPanel[data-tone="blocked"] {
  border-color: var(--color-border-subtle);
  background: color-mix(in srgb, var(--color-bg-subtle) 58%, var(--color-surface-base));
}

@media (max-width: 900px) {
  .dash__topbar {
    padding: 0 var(--space-4);
  }

  .dash__main,
  .dash__footer {
    padding-inline: var(--space-4);
  }

  .ui-pageHeader {
    align-items: stretch;
  }

  .ui-pageHeader__actions,
  .ui-topbar__right,
  .ui-topbar__user {
    width: auto;
    justify-content: flex-start;
  }

  .ui-topbar__right {
    flex-wrap: nowrap;
    min-width: 0;
  }

  .ui-topbar__theme {
    flex: 0 1 6.25rem;
    min-width: 6.25rem;
    width: auto;
  }

  .ui-tablePanel__head,
  .ui-sqlConsole__panelHead,
  .ui-managedViewsPanel__head {
    padding: var(--space-4);
  }

  .ui-tablePanel__tools {
    width: 100%;
    align-items: stretch;
  }

  .ui-tablePanel__controls {
    width: 100%;
  }

  .ui-topbar__themeSelect {
    min-width: 0;
  }

  .ui-topbar__user {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .ui-tablePanel__body,
  .ui-sqlConsole__panelBody,
  .ui-managedViewsPanel__body,
  .ui-queryModal__content,
  .ui-sqlModal__content,
  .ui-sqlLoadModal__content {
    padding: var(--space-4);
  }
}
