:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #1d2733;
  --muted: #667484;
  --line: #dbe1e7;
  --line-strong: #c9d1da;
  --blue: #2468b2;
  --blue-dark: #184d85;
  --blue-soft: #eaf2fb;
  --green: #187a55;
  --green-soft: #e8f6ef;
  --amber: #946200;
  --amber-soft: #fff5d9;
  --red: #b33b3b;
  --red-soft: #fdecec;
  --shadow: 0 8px 24px rgba(25, 39, 52, 0.08);
  --radius: 8px;
  font-family:
    Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  background: #16283a;
  color: #eaf0f5;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 24px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #ffffff;
  color: #163e68;
  font-size: 14px;
  font-weight: 800;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
}

.brand-caption {
  margin-top: 1px;
  color: #aab8c5;
  font-size: 12px;
}

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

.nav-item {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  text-align: left;
  background: transparent;
  color: #b9c6d2;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #243c53;
  color: #ffffff;
}

.sidebar-section {
  margin-top: 28px;
  padding: 14px 12px;
  border: 1px solid #35506a;
  border-radius: var(--radius);
}

.sidebar-label {
  color: #91a3b4;
  font-size: 11px;
  text-transform: uppercase;
}

.current-scenario {
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.45;
}

.sample-badge {
  width: fit-content;
  margin-top: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  background: #304e69;
  color: #c9d8e5;
  font-size: 10px;
  letter-spacing: 0.03em;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 0;
  color: #8fa1b2;
  font-size: 11px;
  line-height: 1.5;
}

.sidebar-footer p {
  margin: 2px 0;
}

.main-content {
  min-width: 0;
}

.topbar {
  min-height: 88px;
  padding: 20px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.eyebrow,
.panel-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 22px;
}

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

.view {
  display: none;
  padding: 28px 30px 52px;
}

.view.active {
  display: block;
}

.intro-row,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.intro-row h2,
.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.intro-row p,
.section-heading p {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.principle-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.principle-strip span {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: #516171;
  font-size: 10px;
}

.scenario-selector {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.scenario-card {
  min-height: 112px;
  padding: 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  gap: 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.scenario-card:hover {
  border-color: #9fb9d4;
}

.scenario-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(36, 104, 178, 0.1);
}

.scenario-card strong {
  align-self: center;
  font-size: 14px;
}

.scenario-card > span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.scenario-type {
  width: 42px;
  height: 24px;
  display: grid;
  place-items: center;
  grid-row: span 2;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 700;
}

.workspace-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(440px, 1.38fr);
  gap: 16px;
  align-items: start;
}

.panel,
.result-card,
.architecture-board {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  padding: 18px;
}

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

.panel-heading h3 {
  margin: 3px 0 0;
  font-size: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 10px;
  white-space: nowrap;
}

.status-pill.neutral {
  background: #edf0f3;
  color: #546373;
}

.status-pill.success {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.danger {
  background: var(--red-soft);
  color: var(--red);
}

.profile-card {
  margin-top: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.profile-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.profile-name-row strong {
  font-size: 14px;
}

.profile-tags {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-tag {
  padding: 4px 7px;
  border-radius: 4px;
  background: #e9eef3;
  color: #516171;
  font-size: 10px;
}

.profile-detail {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.profile-detail span {
  color: var(--muted);
  font-size: 10px;
}

.profile-detail strong {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
}

.field-label {
  display: block;
  margin: 16px 0 7px;
  color: #4f5d6b;
  font-size: 11px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 104, 178, 0.1);
}

.request-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.primary {
  background: var(--blue);
  color: #ffffff;
}

.button.primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.button.secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: #445362;
}

.button.secondary:hover:not(:disabled) {
  background: #f4f6f8;
}

.button.compact {
  min-height: 32px;
  padding: 6px 10px;
}

.button.approve {
  background: var(--green);
  color: #ffffff;
}

.disclaimer-box {
  margin-top: 14px;
  padding: 9px 10px;
  border-left: 3px solid #d4a32a;
  background: var(--amber-soft);
  color: #725619;
  font-size: 10px;
  line-height: 1.5;
}

.runtime {
  color: var(--muted);
  font-size: 10px;
}

.agent-flow {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(7, minmax(70px, 1fr));
  gap: 8px;
}

.agent-step {
  position: relative;
  min-height: 80px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
}

.agent-step::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -9px;
  width: 9px;
  height: 1px;
  background: var(--line-strong);
}

.agent-step:last-child::after {
  display: none;
}

.agent-step .agent-index {
  color: #7b8997;
  font-size: 9px;
}

.agent-step strong {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.4;
}

.agent-step small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
}

.agent-step.running {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 2px rgba(36, 104, 178, 0.09);
}

.agent-step.completed {
  border-color: #98c9b5;
  background: var(--green-soft);
}

.agent-step.skipped {
  border-style: dashed;
  opacity: 0.6;
}

.agent-step.gated {
  border-color: #dab96a;
  background: var(--amber-soft);
}

.execution-log {
  height: 286px;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
}

.compact-empty {
  min-height: 100%;
}

.log-item {
  padding: 12px 13px;
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.log-item:last-child {
  border-bottom: 0;
}

.log-agent {
  color: var(--blue-dark);
  font-size: 10px;
  font-weight: 700;
}

.log-content strong {
  font-size: 11px;
}

.log-content p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.results-section {
  margin-top: 28px;
}

.results-section[hidden],
.approval-panel[hidden] {
  display: none;
}

.result-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.summary-chip {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
}

.result-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.result-card {
  padding: 16px;
}

.result-card.wide {
  grid-column: 1 / -1;
}

.result-card h3 {
  margin: 0;
  font-size: 14px;
}

.result-card h4 {
  margin: 14px 0 5px;
  color: var(--blue-dark);
  font-size: 11px;
}

.result-card p,
.result-card li {
  color: #445260;
  font-size: 11px;
  line-height: 1.6;
}

.result-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.result-card li + li {
  margin-top: 4px;
}

.evidence-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.evidence-item {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}

.evidence-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 9px;
}

.evidence-item strong {
  display: block;
  margin-top: 5px;
  font-size: 10px;
}

.evidence-item p {
  margin: 4px 0 0;
  font-size: 10px;
}

.draft-layout {
  margin-top: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.6fr);
  gap: 14px;
}

.draft-copy,
.advisor-notes {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}

.draft-copy p,
.advisor-notes p {
  margin: 0;
}

.draft-copy p + p {
  margin-top: 8px;
}

.compliance-card {
  border-left: 4px solid var(--amber);
}

.compliance-grid {
  margin-top: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.compliance-block {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.compliance-block strong {
  font-size: 11px;
}

.compliance-block p {
  margin: 6px 0 0;
}

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

.approval-panel {
  margin-top: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid #dcb968;
  border-radius: var(--radius);
  background: var(--amber-soft);
}

.approval-panel.approved {
  border-color: #8fc4aa;
  background: var(--green-soft);
}

.approval-panel h3 {
  margin: 0;
  font-size: 14px;
}

.approval-panel p {
  margin: 5px 0 0;
  color: #6f5b2a;
  font-size: 11px;
}

.approval-panel.approved p {
  color: #3d6f59;
}

.standalone-heading {
  margin-bottom: 18px;
}

.architecture-board {
  padding: 22px;
  display: grid;
  justify-items: center;
  box-shadow: var(--shadow);
}

.architecture-entry,
.router-node,
.human-gate {
  min-width: 280px;
  padding: 9px 14px;
  border-radius: 5px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
}

.architecture-entry {
  border: 1px solid var(--line-strong);
  background: #f3f5f7;
}

.output-entry {
  color: var(--green);
  border-color: #9fcbb8;
  background: var(--green-soft);
}

.router-node {
  color: var(--blue-dark);
  border: 1px dashed #82a8cd;
  background: var(--blue-soft);
}

.human-gate {
  color: var(--amber);
  border: 1px solid #d7b25c;
  background: var(--amber-soft);
}

.architecture-arrow {
  padding: 4px 0;
  color: #8e9aa6;
  font-size: 18px;
}

.architecture-node {
  width: 240px;
  min-height: 78px;
  padding: 12px;
  border: 1px solid #aac0d5;
  border-radius: 6px;
  background: #f7fafc;
  text-align: center;
}

.architecture-node span {
  color: var(--blue);
  font-size: 9px;
  font-weight: 700;
}

.architecture-node strong,
.architecture-node small {
  display: block;
}

.architecture-node strong {
  margin-top: 4px;
  font-size: 12px;
}

.architecture-node small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.primary-node {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.gate-node {
  border-color: #d0a441;
  background: var(--amber-soft);
}

.success-node {
  border-color: #77b799;
  background: var(--green-soft);
}

.branch-grid,
.parallel-grid {
  width: min(680px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 36px;
}

.branch-column {
  display: grid;
  justify-items: center;
}

.branch-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 9px;
}

.parallel-grid {
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.parallel-grid .architecture-node {
  width: 100%;
}

.parallel-label {
  color: var(--muted);
  font-size: 9px;
}

.mapping-section {
  margin-top: 30px;
}

.mapping-table-wrap,
.ledger-table-wrap {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.mapping-table,
.ledger-table {
  width: 100%;
  border-collapse: collapse;
}

.mapping-table th,
.mapping-table td,
.ledger-table th,
.ledger-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 11px;
  line-height: 1.5;
}

.mapping-table th,
.ledger-table th {
  background: #f3f5f7;
  color: #536170;
  font-size: 10px;
}

.mapping-table tr:last-child td,
.ledger-table tr:last-child td {
  border-bottom: 0;
}

.mapping-table td:nth-child(2) {
  color: var(--blue-dark);
  font-weight: 700;
}

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

.kpi-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.kpi-label {
  color: var(--muted);
  font-size: 10px;
}

.kpi-value {
  margin-top: 7px;
  font-size: 22px;
  font-weight: 700;
}

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

.ledger-panel {
  margin-top: 16px;
}

.ledger-table-wrap {
  margin-top: 14px;
}

.ledger-table {
  min-width: 850px;
}

.ledger-table td {
  font-size: 10px;
}

.table-status {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 9px;
}

.table-status.pending {
  background: var(--amber-soft);
  color: var(--amber);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: 6px;
  background: #203344;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 11px;
  line-height: 1.5;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .agent-flow {
    grid-template-columns: repeat(4, minmax(80px, 1fr));
  }

  .agent-step::after {
    display: none;
  }

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

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

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 13px 14px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
  }

  .brand-block {
    padding: 0;
  }

  .nav-list {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .nav-item {
    width: auto;
    padding: 8px 9px;
    text-align: center;
    font-size: 11px;
  }

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

  .topbar {
    min-height: 70px;
    padding: 14px 16px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar-actions .status-pill {
    display: none;
  }

  .view {
    padding: 20px 16px 40px;
  }

  .intro-row,
  .section-heading {
    display: block;
  }

  .principle-strip,
  .result-summary {
    margin-top: 12px;
    justify-content: flex-start;
  }

  .scenario-selector,
  .result-grid,
  .draft-layout,
  .compliance-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

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

  .approval-panel {
    display: block;
  }

  .approval-panel .button {
    width: 100%;
    margin-top: 12px;
  }

  .branch-grid {
    gap: 12px;
  }

  .parallel-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .parallel-label {
    text-align: center;
  }

  .architecture-node {
    width: 100%;
  }

  .architecture-entry,
  .router-node,
  .human-gate {
    min-width: 0;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
