:root {
  color-scheme: light;
  --ink: #152238;
  --muted: #66758a;
  --quiet: #8b98aa;
  --line: #dce3eb;
  --line-strong: #c9d3df;
  --paper: #ffffff;
  --canvas: #f4f7fa;
  --navy: #173f63;
  --navy-2: #245b82;
  --teal: #1f8a70;
  --teal-soft: #e7f5f0;
  --orange: #d95d39;
  --orange-soft: #fceee9;
  --gold: #b88722;
  --selected: #fff4d8;
  --shadow: 0 8px 28px rgba(26, 46, 72, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

button, input, select { font: inherit; }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(36, 91, 130, .22);
  outline-offset: 1px;
}

.topbar {
  min-height: 102px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 20px 28px;
  color: #fff;
  background:
    radial-gradient(circle at 76% -80%, rgba(111, 204, 186, .32), transparent 47%),
    linear-gradient(115deg, #123451, #1b4a6d 58%, #1f6172);
  box-shadow: 0 5px 20px rgba(18, 52, 81, .22);
}

.eyebrow, .panel-kicker {
  color: #86d7c6;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .14em;
}

.brand h1 { margin: 3px 0 5px; font-size: 24px; letter-spacing: .02em; }
.brand p { margin: 0; color: #d5e7ef; font-size: 13px; }

.headline-stats { display: flex; align-items: stretch; }
.headline-stats > div {
  min-width: 112px;
  padding: 5px 18px;
  border-left: 1px solid rgba(255,255,255,.2);
}
.headline-stats strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.headline-stats span { display: block; margin-top: 3px; color: #c7dce6; font-size: 10px; }

.view-tabs {
  min-height: 52px;
  display: flex;
  align-items: stretch;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.view-tab {
  min-width: 132px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}
.view-tab span { margin-right: 7px; color: #a0adbc; font-size: 10px; }
.view-tab:hover { color: var(--navy-2); background: #f8fafc; }
.view-tab.active { color: var(--navy); border-bottom-color: var(--teal); }
.view-tab.active span { color: var(--teal); }
.view-description { margin-left: auto; align-self: center; color: var(--muted); font-size: 11px; }

.workspace {
  height: calc(100vh - 154px);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(292px, 330px) minmax(440px, 1fr) minmax(296px, 330px);
  gap: 12px;
  padding: 12px;
}

.panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.tree-panel, .inspector-panel { overflow: auto; padding: 16px; }
.network-panel { position: relative; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }

.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-heading.compact { align-items: center; }
.panel-kicker { color: var(--teal); }
.panel h2 { margin: 3px 0 0; font-size: 15px; }

.quiet-link, .quiet-button {
  border: 0;
  color: var(--navy-2);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  font-size: 11px;
}
.quiet-link:hover, .quiet-button:hover { text-decoration: underline; }

.field { display: grid; gap: 5px; color: #506176; font-size: 11px; }
.field-heading { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.field-heading label { min-width: 0; }
.info-tip {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 17px;
  padding: 0;
  border: 1px solid #aebbc9;
  border-radius: 50%;
  color: #51677c;
  background: #fff;
  cursor: help;
  font: 600 10px Georgia, serif;
}
.info-tip:hover, .info-tip:focus-visible { color: #fff; border-color: var(--navy-2); background: var(--navy-2); }
.help-popover {
  position: fixed;
  z-index: 50;
  width: min(330px, calc(100vw - 20px));
  padding: 10px 11px;
  border: 1px solid #b8c7d5;
  border-radius: 8px;
  color: #edf6f8;
  background: #203b52;
  box-shadow: 0 9px 28px rgba(18, 45, 66, .24);
  font-size: 10px;
  line-height: 1.62;
  pointer-events: none;
}
.field input, .field select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 7px 9px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(36,91,130,.1); }
.search-field { margin-top: 15px; }
.input-with-icon { position: relative; }
.input-with-icon > span { position: absolute; left: 10px; top: 7px; color: var(--quiet); font-size: 16px; }
.input-with-icon input { padding-left: 31px; }

.search-results {
  max-height: 280px;
  margin-top: 7px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.search-item {
  width: 100%;
  display: block;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid #edf1f5;
  color: inherit;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover { background: #f2f8f6; }
.search-item strong { color: var(--navy-2); font: 650 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.search-item b { float: right; color: var(--teal); font-size: 9px; font-weight: 650; }
.search-item span { display: block; margin-top: 2px; font-size: 11px; line-height: 1.4; }
.search-empty { padding: 12px; color: var(--muted); font-size: 11px; }

.tree-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.small-button, .icon-button {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: #40536a;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
}
.small-button { padding: 6px 8px; }
.small-button:hover, .icon-button:hover { color: var(--navy-2); border-color: #8da9bf; background: #f7fafc; }
.focus-note {
  margin-bottom: 8px;
  padding: 7px 9px;
  border-left: 3px solid var(--teal);
  color: #365d58;
  background: var(--teal-soft);
  font-size: 10px;
  line-height: 1.45;
}

.tree { min-width: 0; padding: 3px 0 20px; }
.tree-row {
  min-width: max-content;
  min-height: 29px;
  display: flex;
  align-items: center;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.tree-row:hover { background: #f1f6f8; }
.tree-row.selected { background: var(--selected); }
.tree-guides { display: inline-flex; align-self: stretch; flex: 0 0 auto; }
.tree-guide { position: relative; width: 16px; align-self: stretch; }
.tree-guide.vertical::before { content: ""; position: absolute; inset: 0 auto 0 8px; border-left: 1px solid #d5dde6; }
.tree-joint { position: relative; width: 19px; align-self: stretch; flex: 0 0 19px; }
.tree-joint::before { content: ""; position: absolute; top: 0; left: 8px; height: 14px; border-left: 1px solid #d5dde6; }
.tree-joint:not(.last)::before { height: 100%; }
.tree-joint::after { content: ""; position: absolute; top: 14px; left: 8px; width: 10px; border-top: 1px solid #d5dde6; }
.tree-toggle {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 17px;
  margin-right: 5px;
  border: 1px solid #b9c6d3;
  border-radius: 4px;
  color: var(--navy-2);
  background: #fff;
  font-size: 10px;
}
.tree-toggle.empty { border-color: transparent; color: #abb5c1; background: transparent; }
.tree-code {
  min-width: 67px;
  margin-right: 6px;
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--navy);
  background: #edf4f8;
  font: 650 10px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tree-title { max-width: 210px; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.tree-level { margin-left: 6px; padding: 2px 5px; border-radius: 8px; color: var(--muted); background: #f1f3f6; font-size: 8px; }
.tree-count { min-width: 150px; margin-left: auto; padding: 0 5px 0 10px; color: #98a4b3; font-size: 8px; text-align: right; }

.network-toolbar {
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
}
.graph-title { font-size: 14px; font-weight: 700; }
.graph-status { margin-top: 3px; color: var(--muted); font-size: 10px; }
.toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.icon-button { padding: 6px 8px; }
#cy { width: 100%; height: 100%; min-height: 420px; background: radial-gradient(circle at center, #fff 0, #fbfcfd 55%, #f2f5f8 100%); }
.empty-graph { position: absolute; inset: 44% 20% auto; z-index: 2; display: grid; gap: 5px; color: var(--muted); text-align: center; font-size: 11px; pointer-events: none; }
.empty-graph strong { color: var(--ink); font-size: 13px; }
.graph-footer {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 9px;
}
.legend { display: flex; flex-wrap: wrap; gap: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-line { width: 18px; border-top: 2px solid; }
.legend-line.positive { border-color: var(--teal); }
.legend-line.negative { border-color: var(--orange); }
.legend-line.additional { border-color: var(--gold); border-top-style: dashed; }
.legend-node { width: 10px; height: 10px; border: 2px solid #53667b; background: #fff; transform: rotate(45deg); }

.inspector-section + .inspector-section { padding-top: 15px; margin-top: 16px; border-top: 1px solid var(--line); }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 9px; margin-top: 14px; }
.check-field { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: #465970; font-size: 10px; cursor: pointer; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.check-row .info-tip { margin-top: 12px; }
.method-note { margin-top: 10px; padding: 8px 9px; border-radius: 7px; color: #607084; background: #f3f6f8; font-size: 9px; line-height: 1.5; }
.details-section h2 { margin-bottom: 10px; }
.details { color: #40536a; font-size: 10px; line-height: 1.55; }
.details h3 { margin: 0 0 3px; color: var(--ink); font-size: 15px; }
.details .subhead { color: var(--muted); font-size: 10px; }
.details dl { display: grid; grid-template-columns: 94px 1fr; gap: 6px 8px; margin: 13px 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.detail-callout { padding: 9px 10px; border-left: 3px solid var(--teal); background: var(--teal-soft); line-height: 1.55; }
.detail-callout.negative { border-color: var(--orange); background: var(--orange-soft); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.detail-action {
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--navy-2);
  background: #fff;
  cursor: pointer;
  font-size: 9px;
}
.detail-list { margin: 11px 0 0; padding: 0; list-style: none; }
.detail-list li { border-top: 1px solid #edf1f4; }
.detail-list button { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 7px 2px; border: 0; color: inherit; background: transparent; text-align: left; cursor: pointer; }
.detail-list button:hover { color: var(--navy-2); }
.detail-list small { color: var(--muted); }
.path { margin-top: 8px; color: var(--muted); line-height: 1.6; }

@media (max-width: 1180px) {
  .workspace { height: auto; grid-template-columns: 300px minmax(480px, 1fr); }
  .inspector-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .inspector-section + .inspector-section { padding-top: 0; margin-top: 0; padding-left: 20px; border-top: 0; border-left: 1px solid var(--line); }
  .network-panel { min-height: 670px; }
}

@media (max-width: 800px) {
  .topbar { align-items: flex-start; padding: 17px 18px; }
  .headline-stats { display: none; }
  .view-tabs { padding: 0 8px; overflow-x: auto; }
  .view-tab { min-width: 118px; }
  .view-description { display: none; }
  .workspace { grid-template-columns: 1fr; padding: 8px; }
  .tree-panel { max-height: 520px; }
  .network-panel { min-height: 640px; }
  .inspector-panel { grid-column: auto; display: block; }
  .inspector-section + .inspector-section { padding-top: 15px; margin-top: 16px; padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .graph-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .brand h1 { font-size: 19px; }
  .brand p { font-size: 11px; }
  .toolbar-actions { max-width: 180px; }
  .filter-grid { grid-template-columns: 1fr; }
}
