:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --ink: #172027;
  --muted: #66737f;
  --line: #d9e1e7;
  --line-strong: #c2cdd6;
  --teal: #0f7c75;
  --teal-2: #0a5c57;
  --blue: #245f9f;
  --amber: #b47712;
  --red: #b84444;
  --green: #25724c;
  --slate: #2b3640;
  --shadow: 0 14px 40px rgba(23, 32, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

body {
  overflow-x: hidden;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

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

.side-nav {
  background: #172027;
  color: #e9f0f4;
  padding: 22px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(145deg, #1b8b82, #245f9f);
  display: grid;
  place-items: center;
  font-weight: 800;
  border-radius: 8px;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.brand-subtitle {
  font-size: 12px;
  color: #9fb0bd;
  margin-top: 2px;
}

.nav-section {
  margin: 16px 0 8px;
  padding: 0 8px;
  color: #8ea0ad;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-link {
  min-height: 38px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 8px;
  color: #c9d5dc;
  font-size: 13px;
}

.nav-link.active {
  background: rgba(19, 139, 129, 0.22);
  color: #ffffff;
  border: 1px solid rgba(89, 214, 200, 0.24);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 11px;
  font-weight: 800;
}

.main {
  min-width: 0;
  padding: 22px 26px 34px;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
}

.page-kicker {
  color: var(--teal-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.page-title {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 760;
}

.page-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: default;
}

.btn.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.btn.dark {
  border-color: var(--slate);
  background: var(--slate);
  color: #fff;
}

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

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

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

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

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

.panel {
  padding: 18px;
}

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

.panel-title {
  font-size: 15px;
  font-weight: 800;
}

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

.metric {
  padding: 16px;
  min-height: 112px;
  cursor: pointer;
}

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

.metric-value {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 780;
}

.metric-trend {
  margin-top: 8px;
  font-size: 12px;
  color: var(--green);
  font-weight: 700;
}

.status-row,
.run-row,
.evidence-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.status-row:last-child,
.run-row:last-child,
.evidence-row:last-child {
  border-bottom: 0;
}

.row-title {
  font-size: 13px;
  font-weight: 760;
}

.row-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  background: #edf2f5;
  color: var(--slate);
  white-space: nowrap;
}

.cell-link {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}

.cell-link:hover {
  text-decoration: underline;
}

.clickable {
  cursor: pointer;
}

.detail-drawer {
  position: fixed;
  right: 358px;
  top: 82px;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(23, 32, 39, 0.2);
  padding: 16px;
  z-index: 20;
  display: none;
}

.detail-drawer.open {
  display: block;
}

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

.detail-title {
  font-weight: 820;
  font-size: 15px;
}

.detail-body {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.detail-close {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
}

.badge.green {
  background: #e4f3ec;
  color: var(--green);
}

.badge.amber {
  background: #fff1d8;
  color: var(--amber);
}

.badge.red {
  background: #fde8e8;
  color: var(--red);
}

.badge.blue {
  background: #e7f0fa;
  color: var(--blue);
}

.table-panel {
  overflow: hidden;
}

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

.data-table th {
  text-align: left;
  background: #f4f7f9;
  color: #52616d;
  font-size: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

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

.map-surface {
  min-height: 344px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(36, 95, 159, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(36, 95, 159, 0.05) 1px, transparent 1px),
    #f8fbfc;
  background-size: 32px 32px;
  position: relative;
  overflow: hidden;
}

.zone {
  position: absolute;
  border: 1px solid rgba(23, 32, 39, 0.12);
  opacity: 0.86;
}

.zone.low {
  background: rgba(37, 114, 76, 0.16);
}

.zone.mid {
  background: rgba(180, 119, 18, 0.18);
}

.zone.high {
  background: rgba(184, 68, 68, 0.2);
}

.sample-dot {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(23, 32, 39, 0.18);
}

.sample-dot.high {
  background: var(--red);
}

.sample-dot.mid {
  background: var(--amber);
}

.sample-dot.low {
  background: var(--green);
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-item {
  display: grid;
  gap: 6px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--teal);
}

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

.flow-step {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.step-index {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8f4f2;
  color: var(--teal-2);
  font-weight: 800;
  font-size: 12px;
}

.input-line,
.textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 38px;
}

.textarea {
  min-height: 128px;
  resize: vertical;
}

.copilot {
  background: #fbfcfd;
  border-left: 1px solid var(--line);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

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

.copilot-title {
  font-size: 15px;
  font-weight: 820;
}

.model-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 5px 7px;
  color: var(--teal-2);
  background: #e4f4f1;
  border-radius: 999px;
}

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

.message {
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.message.user {
  background: #eef7f5;
  border-color: #c6e7e1;
}

.js-agent-output {
  max-height: 52vh;
  overflow: auto;
}

.markdown-body {
  color: var(--ink);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 12px 0 8px;
  line-height: 1.25;
}

.markdown-body h1 {
  font-size: 18px;
}

.markdown-body h2 {
  font-size: 16px;
}

.markdown-body h3,
.markdown-body h4 {
  font-size: 14px;
}

.markdown-body p {
  margin: 8px 0;
}

.markdown-body ul,
.markdown-body ol {
  margin: 8px 0;
  padding-left: 20px;
}

.markdown-body li {
  margin: 5px 0;
}

.markdown-body strong {
  font-weight: 820;
}

.markdown-body em {
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.markdown-body code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  background: #eef2f5;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 4px;
}

.markdown-body pre {
  margin: 10px 0;
  padding: 10px;
  background: #172027;
  color: #eef6f8;
  border-radius: 8px;
  overflow: auto;
  white-space: pre-wrap;
}

.markdown-body pre code {
  display: block;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
}

.markdown-body blockquote {
  margin: 10px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--amber);
  background: #fff8ea;
  color: #5b4a2a;
}

.markdown-body table {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 12px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  background: #f4f7f9;
  font-weight: 800;
}

.markdown-body a {
  color: var(--blue);
  text-decoration: underline;
}

.stream-cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 2px;
  background: var(--teal);
  vertical-align: -2px;
  animation: blink 0.9s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.prompt-box {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px 12px;
  font-size: 13px;
  align-items: center;
}

.config-label {
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 238px minmax(0, 1fr);
  }

  .copilot {
    grid-column: 1 / -1;
    height: auto;
    position: static;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .detail-drawer {
    right: 18px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .side-nav {
    height: auto;
    position: static;
  }

  .main {
    padding: 18px 14px;
  }

  .topbar,
  .panel-header {
    display: grid;
  }

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

  .page-title {
    font-size: 22px;
  }
}
