:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --ink: #17202a;
  --muted: #667381;
  --line: #d8e0e8;
  --blue: #2563eb;
  --blue-dark: #1e3a8a;
  --green: #0f766e;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 16px 36px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #152033;
  color: #e8eef7;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: var(--blue);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.brand p {
  margin: 4px 0 0;
  color: #b6c2d1;
  font-size: 12px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: #c7d2e1;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #ffffff;
  font-size: 17px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  color: #b6c2d1;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 999px;
}

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

.topbar,
.panel-header,
.toolbar,
.test-console {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.topbar h2,
.toolbar h3,
.panel h3 {
  margin: 0;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.2;
}

.topbar-actions,
.toolbar-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.profile-button,
.primary-button,
.secondary-button,
.filter-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  color: var(--blue-dark);
  background: var(--surface);
  font-weight: 800;
}

.profile-button,
.secondary-button,
.filter-button {
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface);
}

.filter-button.active {
  color: #ffffff;
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.primary-button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 700;
}

.full-width {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 20px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 18px;
}

.metric-card.urgent {
  border-color: #f0b4ae;
}

.metric-card span,
.metric-card small,
.panel p,
.toolbar p,
.field span,
.detail-grid span,
.client-list small,
.library-list span,
.audit-list span,
.report-list span,
.retry-list span,
.task-table small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 34px;
  line-height: 1;
}

.panel,
.toolbar {
  padding: 18px;
}

.panel-header p,
.toolbar p,
.test-console p {
  margin: 6px 0 0;
  font-size: 14px;
}

.dashboard-grid,
.review-layout,
.task-layout,
.api-grid,
.system-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 20px;
}

.dashboard-grid .wide {
  min-width: 0;
}

.data-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 14px;
}

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

.data-table th {
  color: var(--muted);
  font-weight: 700;
}

.badge,
.risk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge.published,
.risk.low {
  color: #065f46;
  background: #dff8eb;
}

.badge.testing,
.badge.running,
.risk.medium {
  color: #92400e;
  background: #fff2d9;
}

.badge.draft {
  color: #334155;
  background: #e7edf3;
}

.badge.reviewing {
  color: var(--blue-dark);
  background: #e8f0ff;
}

.badge.failed,
.risk.high {
  color: var(--red);
  background: #fde8e6;
}

.bar-list,
.report-list,
.alert-list,
.client-list,
.retry-list,
.audit-list,
.library-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.bar-list div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
}

.bar-list strong {
  display: block;
  height: 10px;
  background: var(--blue);
  border-radius: 999px;
}

.bar-list em {
  color: var(--muted);
  font-style: normal;
}

.report-list article,
.client-list article,
.retry-list article,
.audit-list article,
.library-list article {
  display: grid;
  gap: 6px;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.alert-list article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.alert-list p {
  margin: 4px 0 0;
}

.stepper,
.pipeline,
.flow-line {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

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

.stepper span,
.pipeline div,
.flow-line div {
  min-height: 44px;
  padding: 12px;
  text-align: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.stepper span.active,
.pipeline div.done {
  color: #ffffff;
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

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

.upload-zone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 170px;
  margin-top: 16px;
  padding: 22px;
  border: 1px dashed #8ca0b3;
  border-radius: 8px;
  background: #f8fbfd;
  text-align: center;
}

.form-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

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

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

.risk-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.risk-summary div,
.detail-grid article {
  display: grid;
  gap: 6px;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.risk-summary span {
  font-size: 28px;
  font-weight: 800;
}

.issue-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.issue,
.empty-state {
  padding: 14px;
  background: #ffffff;
  border-left: 4px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.issue.high {
  border-left-color: var(--red);
}

.issue.medium {
  border-left-color: var(--amber);
}

.issue span {
  color: var(--muted);
  font-size: 13px;
}

.issue h4 {
  margin: 6px 0;
}

.issue p,
.empty-state p {
  margin: 0 0 10px;
}

.issue button {
  min-height: 32px;
  color: var(--blue-dark);
  background: #eef4ff;
  border: 1px solid #c9dafc;
  border-radius: 8px;
}

.task-row {
  cursor: pointer;
}

.task-row.active,
.task-row:hover {
  background: #f1f6ff;
}

.skill-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
}

.skill-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.skill-item {
  display: grid;
  gap: 6px;
  min-height: 74px;
  padding: 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.skill-item.active,
.skill-item:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.skill-item span {
  color: var(--muted);
  font-size: 13px;
}

.tab-row {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
}

.tab.active {
  color: var(--blue-dark);
  border-bottom-color: var(--blue);
  font-weight: 800;
}

.prompt-panel,
.workflow-builder,
.test-console,
.test-result {
  margin-top: 18px;
}

.prompt-panel {
  padding: 14px;
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.prompt-panel h4,
.workflow-builder h4,
.test-console h4 {
  margin: 0;
}

.prompt-panel ol {
  margin: 10px 0 0;
  padding-left: 20px;
}

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

.test-result {
  padding: 14px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 8px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.api-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 20px;
}

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px;
  }

  .brand,
  .sidebar-footer {
    display: none;
  }

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

  .nav-item {
    justify-content: center;
  }

  .nav-icon {
    display: none;
  }
}

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

  .topbar,
  .toolbar,
  .panel-header,
  .test-console {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .toolbar-actions,
  .button-row {
    flex-wrap: wrap;
  }

  .metric-grid,
  .dashboard-grid,
  .review-layout,
  .task-layout,
  .api-grid,
  .system-grid,
  .library-grid,
  .form-grid,
  .detail-grid,
  .risk-summary,
  .pipeline,
  .flow-line.compact,
  .stepper,
  .skill-layout {
    grid-template-columns: 1fr;
  }

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