:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef4f7;
  --ink: #17202a;
  --muted: #667284;
  --line: #dce4ec;
  --teal: #0b7c86;
  --teal-2: #d9f0f1;
  --indigo: #304a8c;
  --indigo-2: #e4e9fb;
  --amber: #b16a00;
  --amber-2: #fff2d6;
  --rose: #a93a4a;
  --rose-2: #fae4e8;
  --green: #207a4a;
  --green-2: #e0f3e8;
  --shadow: 0 18px 45px rgba(24, 39, 75, 0.08);
  --radius: 8px;
  --font: "Aptos", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
  overflow-x: hidden;
}

a {
  color: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--teal);
  background: var(--teal-2);
  border: 1px solid #b9dddd;
  border-radius: var(--radius);
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.1;
}

.brand p,
.screen-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.screen-label {
  text-transform: uppercase;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 14px/1.2 var(--font);
}

.phase-nav {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

.phase-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: 13px/1.25 var(--font);
  text-align: left;
}

.phase-button:hover,
.phase-button.active {
  background: var(--surface-2);
  border-color: var(--line);
}

.phase-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--indigo);
  background: var(--indigo-2);
  border-radius: 7px;
  font-weight: 700;
}

.phase-count {
  color: var(--muted);
  font-size: 12px;
}

.side-note {
  display: grid;
  gap: 7px;
  margin-top: 20px;
  padding: 14px;
  border-left: 3px solid var(--teal);
  background: var(--teal-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.side-note span {
  color: #315b63;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

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

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

.topbar h2 {
  max-width: 780px;
  margin: 4px 0 0;
  font-size: 32px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 13px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
}

.icon-button.primary {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 12px;
  margin-bottom: 18px;
}

.status-item {
  display: grid;
  gap: 4px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.status-value {
  font-size: 24px;
  font-weight: 750;
}

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

.status-item.warning {
  background: var(--amber-2);
  border-color: #efd69f;
}

.flow-section,
.artifact-panel,
.detail-panel,
.workbook-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.flow-section,
.workbook-section {
  padding: 18px;
}

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

.section-heading h3 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.2;
}

.result-count {
  color: var(--muted);
  font-size: 13px;
}

.flow-lane {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
}

.flow-node {
  position: relative;
  display: grid;
  gap: 9px;
  min-height: 154px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  cursor: pointer;
  text-align: left;
}

.flow-node:hover,
.flow-node.active {
  border-color: #9bcdd2;
  background: #f2fbfc;
}

.flow-node::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -10px;
  width: 10px;
  border-top: 1px solid #b8c7d6;
}

.flow-node:last-child::after {
  display: none;
}

.flow-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.flow-node h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.flow-node p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.flow-files {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.file-chip,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  color: #32414d;
  background: #eef3f6;
  font-size: 12px;
  line-height: 1;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.65fr);
  gap: 14px;
  margin-top: 14px;
}

.artifact-panel,
.detail-panel {
  min-height: 620px;
  padding: 18px;
}

.artifact-list {
  display: grid;
  gap: 9px;
}

.artifact-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  cursor: pointer;
  text-align: left;
}

.artifact-row:hover,
.artifact-row.active {
  border-color: #a8c7ef;
  background: #f6f9ff;
}

.artifact-code {
  color: var(--indigo);
  font-weight: 750;
  font-size: 13px;
}

.artifact-row h4 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.25;
}

.artifact-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.artifact-meta {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-panel {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.detail-kicker {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.detail-panel h3 {
  margin: 4px 0 10px;
  font-size: 24px;
  line-height: 1.2;
}

.detail-summary {
  margin: 0 0 14px;
  color: #40505d;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.detail-block {
  display: grid;
  gap: 7px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.detail-block h4 {
  margin: 0;
  font-size: 14px;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-list li {
  position: relative;
  padding-left: 15px;
  color: #40505d;
  font-size: 13px;
  line-height: 1.5;
}

.detail-list li::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.workbook-section {
  margin-top: 14px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
}

.sheet-item {
  display: grid;
  gap: 7px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.sheet-item strong {
  font-size: 14px;
}

.sheet-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  color: #ffffff;
  background: #17202a;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.risk-red {
  background: var(--rose-2);
  color: var(--rose);
}

.risk-amber {
  background: var(--amber-2);
  color: var(--amber);
}

.risk-green {
  background: var(--green-2);
  color: var(--green);
}

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

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

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

  .content-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .sidebar,
  .workspace {
    max-width: 100vw;
  }

  .side-note,
  .side-note span,
  .topbar h2 {
    word-break: break-word;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .top-actions .icon-button {
    width: 100%;
  }

  .status-grid,
  .flow-lane,
  .sheet-grid {
    grid-template-columns: 1fr;
  }

  .flow-node::after {
    display: none;
  }

  .artifact-row {
    grid-template-columns: 1fr;
  }

  .artifact-meta {
    justify-content: flex-start;
  }
}
