:root {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f9f9f7;
  --text: #0b0b0b;
  --muted: #898782;
  --line: #f0f0f0;
  --line-strong: #eaeaea;
  --table-head: #f9f9fb;
  --nav-hover: #f0f0ef;
  --accent: #0b0b0b;
  --purple: #722ed1;
  --green: #237804;
  --orange: #ad6800;
  --red: #a8071a;
  --blue: #0958d9;
  font-family: "PingFang SC", "Noto Sans SC", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.layout {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--sidebar);
  padding: 12px;
  box-shadow: inset -4px 0 6px -4px rgba(0, 0, 0, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}

.workspace-select {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  margin-bottom: 8px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.workspace-select:hover {
  background: var(--nav-hover);
  border-color: #dededb;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 0.5px solid transparent;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item,
.nav-subitem {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #000;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item {
  font-weight: 500;
}

.nav-subitem {
  padding-left: 40px;
  font-weight: 400;
}

.nav-item:hover,
.nav-subitem:hover {
  background: var(--nav-hover);
}

.nav-item.active,
.nav-subitem.active {
  background: var(--nav-hover);
  box-shadow: none;
  color: #0b0b0b;
  font-weight: 600;
}

.nav-item svg,
.workspace-select svg {
  width: 20px;
  height: 20px;
  color: #6f6d68;
  flex: 0 0 auto;
}

.chevron {
  margin-left: auto;
  width: 16px;
  height: 16px;
  color: #898782;
}

.main {
  min-width: 0;
  overflow: hidden;
}

.content {
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.title-block h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.title-block p {
  margin: 0;
  color: #000;
  line-height: 20px;
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}

.ghost-button {
  color: var(--text);
  background: transparent;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.search {
  width: min(360px, 38vw);
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

.search:focus,
.filter-select:focus {
  border-color: #b8b8b3;
}

.filter-select {
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 28px 0 10px;
  background: #fff;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: auto;
}

thead {
  background: var(--table-head);
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: #000;
  font-size: 12px;
  font-weight: 600;
}

tbody tr {
  background: #fff;
}

tbody tr:hover {
  background: #fcfcfb;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.muted {
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 16px;
}

.tag-space,
.tag-指标 {
  color: var(--purple);
  background: rgba(114, 46, 209, 0.08);
}

.tag-system,
.tag-系统,
.tag-设备,
.tag-number,
.tag-p0,
.tag-必填,
.tag-必备,
.tag-已发布 {
  color: var(--green);
  background: rgba(82, 196, 26, 0.12);
}

.tag-point,
.tag-bool,
.tag-点位 {
  color: var(--blue);
  background: rgba(22, 119, 255, 0.1);
}

.tag-meter,
.tag-表计,
.tag-空间,
.tag-建议,
.tag-选配,
.tag-草稿 {
  color: var(--orange);
  background: rgba(250, 173, 20, 0.14);
}

.status {
  font-weight: 500;
}

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

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

.status.bad {
  color: var(--red);
}

.status.muted {
  color: var(--muted);
}

.action-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: #0b0b0b;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(0, 0, 0, 0.18);
  z-index: 20;
}

.drawer.open {
  display: block;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(440px, 100vw);
  height: 100%;
  padding: 20px;
  background: #fff;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.drawer-head h2 {
  margin: 0;
  font-size: 18px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 10px;
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.rule-set-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcfb;
}

.rule-set-banner.large {
  background: #fff;
}

.rule-set-banner strong {
  margin-right: 8px;
  font-size: 16px;
}

.rule-set-banner span {
  color: var(--muted);
  font-size: 12px;
}

.version-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.version-detail {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sub-tabs {
  margin-top: 4px;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 500;
}

.flow-step span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--sidebar);
  color: var(--muted);
  font-size: 12px;
}

.flow-step.active {
  color: var(--text);
  border-color: #d8d8d4;
}

.flow-step.active span {
  color: #fff;
  background: var(--accent);
}

.rules-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.rules-tree {
  position: sticky;
  top: 24px;
  min-height: calc(100vh - 128px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rules-tree-title {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

.tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-list .tree-list {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.tree-branch {
  margin-bottom: 6px;
}

.tree-node {
  display: flex;
  align-items: center;
  min-height: 30px;
  color: #4d4b47;
  font-size: 13px;
  font-weight: 500;
}

.tree-leaf {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  margin: 3px 0;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.tree-leaf span {
  font-weight: 500;
}

.tree-leaf small {
  color: var(--muted);
  white-space: nowrap;
}

.tree-leaf.active {
  background: var(--sidebar);
  box-shadow: 0 0 0 1px rgba(11, 11, 11, 0.05);
}

.rules-content {
  min-width: 0;
}

.rules-content-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rules-content-head h2,
.binding-head h3 {
  margin: 0;
  line-height: 28px;
  font-size: 20px;
}

.rules-content-head h2 span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.rule-source {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

.rule-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.rule-tab {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.rule-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.rule-intro {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #4d4b47;
  background: #fcfcfb;
  line-height: 20px;
}

.rule-table table {
  min-width: 1040px;
}

.binding-panel {
  margin-top: 16px;
}

.binding-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.compact-table table {
  min-width: 760px;
}

.relation-summary {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.relation-toolbar {
  align-items: flex-start;
}

.relation-toolbar .toolbar-left {
  flex-wrap: wrap;
}

.relation-toolbar .search {
  width: min(420px, 36vw);
}

.relation-table {
  margin-bottom: 16px;
}

.relation-table table {
  min-width: 2360px;
}

.relation-drawer {
  width: min(560px, 100vw);
}

.workbench-page {
  display: grid;
  grid-template-columns: 220px minmax(430px, 1fr) 270px;
  gap: 8px;
  height: calc(100vh - 168px);
  min-height: 600px;
  overflow: hidden;
}

.object-pool,
.impact-workbench,
.object-inspector {
  min-height: 0;
  overflow: auto;
}

.object-pool {
  border-right: 1px solid var(--line);
  padding-right: 8px;
}

.object-search {
  width: 100%;
  margin-bottom: 8px;
}

.pool-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.pool-filters .filter-select {
  min-width: 0;
  width: 100%;
}

.pool-section-title {
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.pool-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 30px;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.pool-row:hover,
.pool-row.active {
  background: var(--nav-hover);
}

.pool-row span {
  color: var(--muted);
  font-size: 11px;
}

.pool-row.warning span {
  color: var(--orange);
  background: rgba(250, 173, 20, 0.14);
  padding: 1px 4px;
  border-radius: 4px;
}

.pool-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.pool-row em {
  color: #9a9892;
  font-size: 12px;
  font-style: normal;
}

.impact-workbench {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: auto;
}

.impact-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin-bottom: 8px;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
}

.impact-head h1 {
  margin: 0;
  font-size: 14px;
}

.impact-head p {
  margin: 0;
  color: #4d4b47;
  font-size: 12px;
}

.impact-head span {
  color: var(--muted);
}

.impact-columns {
  display: grid;
  grid-template-columns: repeat(5, minmax(132px, 1fr));
  gap: 6px;
  flex: 1;
  width: max(100%, 690px);
  min-height: 0;
}

.impact-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.impact-column-title {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  color: #4d4b47;
  font-size: 11px;
  font-weight: 600;
}

.impact-column-title span {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--sidebar);
  color: #6f6d68;
}

.impact-column-title em {
  color: var(--muted);
  font-style: normal;
}

.impact-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.impact-card {
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.impact-card.active {
  background: #e8f1fb;
  border-color: #d6e6f6;
}

.impact-card.focus {
  min-height: 78px;
  background: #fcfcfb;
}

.impact-card strong,
.impact-card small {
  display: block;
}

.impact-card strong {
  margin-top: 2px;
  font-size: 13px;
}

.impact-card small {
  margin-top: 5px;
  color: var(--muted);
}

.impact-badge {
  color: #6f6d68;
  font-size: 12px;
}

.object-inspector {
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

.inspector-eyebrow,
.panel-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.object-inspector h2 {
  margin: 6px 0;
  font-size: 18px;
}

.inspector-link {
  color: var(--blue);
  font-size: 12px;
  text-decoration: none;
}

.inspector-button {
  width: 100%;
  margin: 10px 0;
}

.inspector-panel {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.relation-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.relation-chip strong {
  color: #4d4b47;
  font-size: 13px;
}

.health-panel {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
}

.health-score {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: rgba(82, 196, 26, 0.14);
  color: var(--green);
  font-size: 18px;
  font-weight: 700;
}

.health-score span {
  font-size: 11px;
}

.health-panel h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.health-panel h3 span {
  color: var(--muted);
  font-family: monospace;
  font-size: 12px;
}

.health-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.health-tags span,
.mini-button {
  border: 0;
  border-radius: 999px;
  background: rgba(82, 196, 26, 0.12);
  color: var(--green);
  padding: 3px 8px;
  font-size: 12px;
}

.mini-button {
  float: right;
  background: rgba(250, 173, 20, 0.14);
  color: var(--orange);
}

.inspector-panel p {
  margin: 8px 0 0;
  color: #6f6d68;
  font-size: 12px;
  line-height: 18px;
}

.meter-card {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.meter-card small,
.meter-card em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.meter-card em {
  color: var(--green);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-group {
    display: contents;
  }

  .summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .rules-shell {
    grid-template-columns: 1fr;
  }

  .version-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rules-tree {
    position: static;
    min-height: 0;
  }

  .rules-content-head,
  .binding-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-left,
  .toolbar-right {
    flex-wrap: wrap;
  }

  .search {
    width: 100%;
  }

  .relation-toolbar .search {
    width: 100%;
  }

  .workbench-page {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .object-pool,
  .object-inspector {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }

  .impact-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 16px;
  }

  .summary-row {
    grid-template-columns: 1fr;
  }

  .version-flow {
    grid-template-columns: 1fr;
  }
}
