:root {
  --bg: #e9edf1;
  --surface: #f8fafb;
  --panel: #ffffff;
  --ink: #16202a;
  --muted: #657282;
  --line: #d9e0e6;
  --navy: #243447;
  --blue: #2f6fdd;
  --green: #23855a;
  --amber: #b7791f;
  --red: #c2413f;
  --teal: #127681;
  --shadow: 0 16px 48px rgba(36, 52, 71, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  background: #111b25;
  color: #eef4f8;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: #1f3449;
  color: #bfe6df;
  font-weight: 800;
  font-size: 14px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
  line-height: 1.2;
}

.brand p {
  margin-top: 4px;
  color: #93a4b7;
  font-size: 12px;
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: grid;
  min-height: 42px;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #d5e0eb;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(104, 166, 255, 0.42);
  background: #203247;
  color: #ffffff;
}

.sidebar-section {
  min-height: 0;
}

.section-label {
  margin-bottom: 10px;
  color: #8295aa;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.line-list,
.equipment-list {
  display: grid;
  gap: 8px;
}

.line-chip,
.equipment-item {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: #eaf1f7;
  text-align: left;
}

.line-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 12px;
}

.equipment-item {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
}

.equipment-item.active {
  border-color: rgba(110, 210, 177, 0.62);
  background: rgba(35, 133, 90, 0.18);
}

.equipment-name-row,
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.equipment-name {
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.equipment-meta {
  color: #99a9bb;
  font-size: 12px;
}

.health-mini {
  width: 54px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.health-mini span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 5px;
  font-size: 28px;
  line-height: 1.15;
}

.topbar-actions,
.prompt-row,
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-button,
.primary-button,
.secondary-button,
.prompt-chip {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 20px;
}

.primary-button {
  padding: 0 16px;
  border-color: #1f5db8;
  background: #1f5db8;
  color: #ffffff;
  font-weight: 700;
}

.secondary-button,
.prompt-chip {
  padding: 0 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.kpi-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 116px;
  padding: 16px;
}

.kpi-value {
  margin-top: 12px;
  font-size: 31px;
  font-weight: 850;
  line-height: 1;
}

.kpi-trend {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.content-grid,
.ontology-layout,
.agent-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 14px;
  align-items: start;
}

.agent-layout {
  grid-template-columns: minmax(420px, 1fr) minmax(300px, 0.58fr) minmax(300px, 0.58fr);
}

.object-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.78fr);
  gap: 14px;
  align-items: start;
}

.object-hero {
  grid-column: span 2;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel h3 {
  margin-top: 4px;
  font-size: 18px;
}

.badge {
  display: inline-grid;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  background: rgba(35, 133, 90, 0.12);
  color: var(--green);
}

.badge.amber {
  background: rgba(183, 121, 31, 0.14);
  color: var(--amber);
}

.badge.red {
  background: rgba(194, 65, 63, 0.13);
  color: var(--red);
}

.badge.blue {
  background: rgba(47, 111, 221, 0.12);
  color: var(--blue);
}

.line-risk-list,
.priority-list,
.signal-grid,
.relation-table,
.timeline,
.model-list,
.doc-list,
.action-list {
  display: grid;
  gap: 10px;
}

.line-risk-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 54px;
  gap: 12px;
  align-items: center;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8ee;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.priority-item,
.relation-row,
.timeline-item,
.model-item,
.doc-item,
.action-item {
  border: 1px solid #e2e8ee;
  border-radius: var(--radius);
  background: #fbfcfd;
}

.priority-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 92px;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.priority-title,
.relation-main,
.timeline-title,
.model-title,
.doc-title,
.action-title {
  font-weight: 800;
}

.muted,
.priority-meta,
.relation-sub,
.timeline-meta,
.model-sub,
.doc-snippet,
.action-meta {
  color: var(--muted);
  font-size: 13px;
}

.object-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 20px;
  align-items: center;
}

.object-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.object-title-row h3 {
  margin: 0;
  font-size: 28px;
}

.object-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.fact {
  min-height: 78px;
  border: 1px solid #e2e8ee;
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.fact-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.fact-value {
  margin-top: 7px;
  font-size: 16px;
  font-weight: 800;
}

.health-ring {
  position: relative;
  display: grid;
  width: 160px;
  height: 160px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--red) 0deg, var(--red) var(--ring), #e5ebf1 var(--ring), #e5ebf1 360deg);
}

.health-ring::after {
  position: absolute;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: var(--panel);
  content: "";
}

.ring-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.ring-value {
  font-size: 34px;
  font-weight: 900;
}

.ring-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.signal-card {
  min-height: 112px;
  border: 1px solid #e2e8ee;
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.signal-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 900;
}

.sparkline {
  display: flex;
  align-items: end;
  gap: 4px;
  height: 34px;
  margin-top: 10px;
}

.sparkline span {
  width: 100%;
  min-width: 5px;
  border-radius: 4px 4px 0 0;
  background: #7a9ccc;
}

.relation-row,
.timeline-item,
.model-item,
.doc-item,
.action-item {
  padding: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
}

.ontology-map {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid #dce4eb;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(36, 52, 71, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(36, 52, 71, 0.05) 1px, transparent 1px),
    #f9fbfc;
  background-size: 28px 28px;
}

.map-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ontology-node {
  position: absolute;
  display: grid;
  width: 156px;
  min-height: 76px;
  place-items: center;
  border: 1px solid #cbd6df;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(36, 52, 71, 0.12);
  text-align: center;
}

.ontology-node.main {
  border-color: rgba(194, 65, 63, 0.42);
  background: #fff8f7;
}

.node-type {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.node-name {
  margin-top: 5px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 850;
}

.chat-window {
  display: grid;
  max-height: 476px;
  min-height: 360px;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.message {
  max-width: 88%;
  border-radius: var(--radius);
  padding: 12px 13px;
  line-height: 1.65;
  font-size: 14px;
}

.message.agent {
  justify-self: start;
  border: 1px solid #dce7ee;
  background: #f5faf8;
}

.message.user {
  justify-self: end;
  background: #1f5db8;
  color: #ffffff;
}

.prompt-row {
  margin: 14px 0 10px;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 8px;
}

.chat-form input {
  min-height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #fbfcfd;
}

.doc-item.active-doc {
  border-color: rgba(47, 111, 221, 0.46);
  background: rgba(47, 111, 221, 0.06);
}

.action-item {
  display: grid;
  gap: 10px;
}

.action-status {
  justify-self: start;
}

.demo-dialog {
  width: min(680px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.demo-dialog::backdrop {
  background: rgba(17, 27, 37, 0.48);
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.dialog-heading h3 {
  margin: 4px 0 0;
  font-size: 22px;
}

.demo-dialog li {
  margin: 10px 0;
  line-height: 1.6;
}

.risk-red {
  color: var(--red);
}

.risk-amber {
  color: var(--amber);
}

.risk-green {
  color: var(--green);
}

@media (max-width: 1180px) {
  .agent-layout,
  .content-grid,
  .ontology-layout,
  .object-layout {
    grid-template-columns: 1fr;
  }

  .object-hero {
    grid-column: auto;
  }

  .object-summary,
  .object-facts {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .workspace {
    padding: 16px;
  }

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

  .kpi-grid,
  .signal-grid,
  .object-summary,
  .object-facts {
    grid-template-columns: 1fr;
  }

  .priority-item,
  .line-risk-row {
    grid-template-columns: 1fr;
  }

  .ontology-map {
    min-height: 720px;
  }
}
