:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #eef4fb;
  --text: #172033;
  --muted: #66738a;
  --line: #d9e2ee;
  --brand: #136f63;
  --brand-2: #1b8a7c;
  --blue: #2f6fbd;
  --amber: #b7791f;
  --red: #b83232;
  --green: #177245;
  --shadow: 0 10px 30px rgba(29, 45, 68, 0.08);
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  background: #142235;
  color: #edf4ff;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 16px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #21a392;
  color: #fff;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: #aebbd0;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #c7d2e5;
  font-size: 14px;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-billing {
  margin-top: auto;
  padding-top: 16px;
}

.sidebar-billing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.sidebar-billing-head strong {
  font-size: 13px;
}

.sidebar-billing-head span,
.sidebar-billing-note {
  color: #aebbd0;
  font-size: 11px;
}

.sidebar-billing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.sidebar-billing-grid div {
  min-height: 54px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-billing-grid span {
  display: block;
  color: #aebbd0;
  font-size: 11px;
}

.sidebar-billing-grid strong {
  display: block;
  margin-top: 5px;
  color: #fff;
  font-size: 13px;
  line-height: 1.2;
  word-break: break-word;
}

.sidebar-billing-note {
  margin-top: 8px;
  line-height: 1.35;
}

.main {
  min-width: 0;
  padding: 22px 28px 36px;
}

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

.eyebrow {
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.select,
.button {
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
}

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

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.grid.align-start {
  align-items: start;
}

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

.panel {
  padding: 16px;
}

.metric {
  min-height: 118px;
  padding: 15px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 12px;
  font-size: 30px;
  font-weight: 800;
}

.metric-unit {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.metric-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

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

.panel-title {
  margin: 0;
  font-size: 17px;
}

.panel-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.chart {
  width: 100%;
  height: 280px;
}

.chart.tall {
  height: 360px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel-2);
  color: var(--text);
}

.badge.low,
.badge.running,
.badge.completed,
.badge.confirmed {
  background: #ddf4e8;
  color: var(--green);
}

.badge.medium,
.badge.warning,
.badge.pending {
  background: #fff0d2;
  color: var(--amber);
}

.badge.high,
.badge.critical {
  background: #ffe0df;
  color: var(--red);
}

.list {
  display: grid;
  gap: 10px;
}

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

.item-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-weight: 800;
}

.item p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 800;
  background: #f8fafc;
}

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

.table-panel {
  overflow: hidden;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline .item {
  border-left: 4px solid var(--brand-2);
}

.agent-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.agent-step {
  min-height: 118px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.agent-step strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.agent-step span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 14px;
}

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

.expert-agent {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(380px, calc(100vw - 28px));
  z-index: 30;
  font-size: 14px;
}

.expert-toggle {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: #136f63;
  color: #fff;
  box-shadow: 0 14px 34px rgba(19, 111, 99, 0.28);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  font: inherit;
  text-align: left;
}

.expert-toggle strong {
  display: block;
  font-size: 14px;
}

.expert-toggle span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
}

.expert-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 800;
  flex: 0 0 auto;
}

.expert-panel {
  display: none;
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(29, 45, 68, 0.18);
  overflow: hidden;
}

.expert-agent.open .expert-panel {
  display: block;
}

.expert-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  background: #142235;
  color: #fff;
}

.expert-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.expert-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.expert-messages {
  height: 280px;
  overflow: auto;
  padding: 13px;
  background: #f8fbff;
  display: grid;
  align-content: start;
  gap: 10px;
}

.expert-message {
  max-width: 88%;
  padding: 9px 10px;
  border-radius: 8px;
  line-height: 1.5;
  font-size: 13px;
}

.expert-message.agent {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.expert-message.user {
  justify-self: end;
  background: #136f63;
  color: #fff;
}

.expert-message p {
  margin: 0 0 8px;
}

.expert-message p:last-child {
  margin-bottom: 0;
}

.expert-message ul {
  margin: 6px 0 8px;
  padding-left: 18px;
}

.expert-message li {
  margin: 3px 0;
}

.expert-message h4 {
  margin: 2px 0 8px;
  font-size: 14px;
}

.expert-message code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #eef4fb;
  color: #142235;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.expert-message pre {
  margin: 8px 0;
  padding: 9px;
  overflow: auto;
  border-radius: 6px;
  background: #142235;
  color: #edf4ff;
}

.expert-message pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.math-inline {
  display: inline-block;
  padding: 0 5px;
  border-radius: 4px;
  background: #eef4fb;
  font-family: Cambria Math, "Times New Roman", serif;
}

.math-block {
  display: block;
  margin: 8px 0;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
  color: #142235;
  font-family: Cambria Math, "Times New Roman", serif;
  text-align: center;
}

.graph-wrap {
  position: relative;
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.graph-svg {
  width: 100%;
  height: 640px;
  display: block;
}

.graph-link {
  stroke: #aebbd0;
  stroke-width: 1.4;
  opacity: 0.38;
}

.graph-link.active {
  stroke: #136f63;
  stroke-width: 2.8;
  opacity: 0.95;
}

.graph-label {
  fill: #66738a;
  font-size: 11px;
  pointer-events: none;
}

.graph-node circle,
.graph-node rect {
  stroke: #fff;
  stroke-width: 2;
  filter: drop-shadow(0 4px 8px rgba(29, 45, 68, 0.18));
}

.graph-node text {
  fill: #172033;
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
  pointer-events: none;
}

.graph-node.dim {
  opacity: 0.24;
}

.graph-node.active circle,
.graph-node.active rect {
  stroke: #142235;
  stroke-width: 3;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kg-compact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin-bottom: 10px;
}

.kg-row-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kg-link-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.kg-link-chip {
  display: inline-flex;
  align-items: center;
  max-width: 360px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.playback-stage {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.playback-control {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.playback-slider {
  flex: 1;
  min-width: 220px;
}

.playback-event.active {
  border-color: var(--brand);
  background: #effaf7;
}

.graph-node {
  cursor: grab;
}

.graph-node.dragging {
  cursor: grabbing;
}

.graph-detail {
  position: absolute;
  right: 14px;
  top: 14px;
  width: min(320px, calc(100% - 28px));
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.expert-quick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 13px 0;
  background: #fff;
}

.expert-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.expert-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 13px 13px;
  background: #fff;
}

.expert-input {
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  font: inherit;
}

.expert-send {
  height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: #136f63;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

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

  .sidebar-billing {
    margin-top: 16px;
  }

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

  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .split,
  .agent-flow {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 18px 14px 28px;
  }

  .topbar {
    display: grid;
  }

  .toolbar {
    justify-content: flex-start;
  }

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

  h1 {
    font-size: 22px;
  }

  .metric-value {
    font-size: 25px;
  }

  .expert-agent {
    right: 14px;
    bottom: 14px;
  }

  .expert-messages {
    height: 240px;
  }
}
