:root {
  --ink: #123027;
  --muted: #5a6f68;
  --line: #d9e3df;
  --surface: #ffffff;
  --page: #f4f7f4;
  --brand: #006b45;
  --brand-strong: #004f36;
  --amber: #d98a0d;
  --blue: #1f72d6;
  --purple: #6b3fb5;
  --orange: #f26d21;
  --danger: #b42318;
  --shadow: 0 16px 38px rgba(18, 48, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 72px;
  padding: 0 48px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-left: auto;
}

.nav-links a {
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

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

.app-shell {
  width: min(1500px, calc(100% - 64px));
  margin: 28px auto 44px;
}

.summary-band {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 18px;
  padding: 24px 8px 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 650px;
  margin-bottom: 8px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
}

.lede {
  max-width: 660px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.proof-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(94px, 1fr));
  gap: 10px;
  min-width: min(100%, 390px);
}

.proof-points span {
  display: grid;
  gap: 2px;
  min-height: 72px;
  padding: 12px;
  align-content: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(18, 48, 39, 0.08);
}

.proof-points strong {
  color: var(--ink);
  font-size: 24px;
}

.builder-grid {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(480px, 1fr) minmax(290px, 370px);
  gap: 12px;
  align-items: stretch;
}

.lower-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1fr 0.9fr;
  gap: 12px;
  margin-top: 12px;
}

.panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 74px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin-bottom: 4px;
  font-size: 17px;
  line-height: 1.2;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.block-list,
.template-list,
.task-list,
.audit-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.block-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.block-item:hover,
.block-item:focus-visible {
  border-color: var(--brand);
  outline: none;
}

.block-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #ffffff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.category-hr {
  background: var(--brand);
}

.category-finance {
  background: var(--amber);
}

.category-operations {
  background: var(--blue);
}

.category-customer_service {
  background: var(--purple);
}

.category-common {
  background: var(--orange);
}

.block-title {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 750;
}

.block-subtitle {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.workflow-heading {
  border-bottom: 0;
}

.workflow-canvas {
  position: relative;
  min-height: 390px;
  margin: 0 12px 12px;
  overflow: hidden;
  background-color: #fbfdfb;
  background-image: radial-gradient(#ccd8d2 1px, transparent 1px);
  background-size: 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.edge-layer,
.node-layer {
  position: absolute;
  inset: 0;
}

.edge-layer path {
  fill: none;
  stroke: #7a9188;
  stroke-width: 2.4;
}

.edge-layer circle {
  fill: #7a9188;
}

.node {
  position: absolute;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  width: 190px;
  min-height: 58px;
  padding: 10px;
  background: #ffffff;
  border: 2px solid #b8d5c7;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(18, 48, 39, 0.12);
}

.node.finance {
  border-color: #f0c36d;
}

.node.operations {
  border-color: #9fc4f2;
}

.node.customer_service {
  border-color: #c8b6ea;
}

.node.common {
  border-color: #f2b27f;
}

.node strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.node span {
  color: var(--muted);
  font-size: 11px;
}

.drop-target {
  position: absolute;
  left: 50%;
  bottom: 28px;
  width: min(440px, calc(100% - 40px));
  min-height: 50px;
  transform: translateX(-50%);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  border: 2px dashed #c3d0cb;
  border-radius: 8px;
}

.drop-target.drag-over {
  color: var(--brand);
  border-color: var(--brand);
  background: #eef8f2;
}

.validation-strip {
  min-height: 40px;
  padding: 10px 16px 14px;
  color: var(--muted);
  font-size: 13px;
}

.validation-strip.ok {
  color: var(--brand-strong);
}

.validation-strip.warn {
  color: #875700;
}

.validation-strip.error {
  color: var(--danger);
}

.primary-button,
.ghost-button,
.text-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 760;
}

.primary-button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--brand);
  border: 1px solid var(--brand);
}

.primary-button:hover {
  background: var(--brand-strong);
}

.ghost-button {
  padding: 0 14px;
  color: var(--brand-strong);
  background: #ffffff;
  border: 1px solid #99b9aa;
}

.text-button {
  min-height: 32px;
  padding: 0 8px;
  color: var(--brand);
  background: transparent;
  border: 0;
}

.icon-button {
  width: 42px;
  color: var(--brand-strong);
  background: #f5faf7;
  border: 1px solid var(--line);
  font-size: 12px;
}

.assistant-panel textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  color: var(--ink);
  background: #f5faf7;
  border: 1px solid #b5cfc3;
  border-radius: 8px;
  padding: 12px;
  line-height: 1.35;
}

.draft-form {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.draft-form .button-row {
  align-items: stretch;
}

.draft-form button {
  flex: 1;
}

.sketch-box {
  margin: 0 14px 12px;
  padding: 12px;
  background: #fffdf8;
  border: 1px solid #edd6a9;
  border-radius: 8px;
}

.sketch-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.sketch-box svg {
  width: 100%;
  height: auto;
}

.sketch-box rect {
  fill: #ffffff;
  stroke: var(--brand);
  stroke-width: 2;
}

.sketch-box rect:nth-of-type(2) {
  stroke: var(--blue);
}

.sketch-box rect:nth-of-type(3) {
  stroke: var(--amber);
}

.sketch-box rect:nth-of-type(4) {
  stroke: var(--purple);
}

.sketch-box path {
  fill: none;
  stroke: #5f766e;
  stroke-width: 2;
}

.sketch-box text {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 760;
  text-anchor: middle;
}

.assistant-result {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 8px;
  margin: 0 14px 14px;
  padding: 12px;
  color: var(--muted);
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  background: var(--brand);
  border-radius: 50%;
}

.template-card,
.task-card,
.audit-card {
  padding: 12px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.template-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.template-card strong,
.task-card strong,
.audit-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.template-card span,
.task-card span,
.audit-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.task-card {
  display: grid;
  gap: 10px;
}

.task-actions {
  display: flex;
  justify-content: flex-end;
}

.empty-state {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.reference-panel {
  cursor: zoom-in;
  touch-action: manipulation;
}

.reference-panel .panel-heading {
  cursor: zoom-in;
}

.reference-preview {
  position: relative;
  display: block;
  width: calc(100% - 28px);
  margin: 14px;
  padding: 0;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: zoom-in;
  touch-action: manipulation;
}

.reference-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top left;
}

.reference-preview span {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 7px 10px;
  color: #ffffff;
  background: rgba(0, 79, 54, 0.92);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.reference-preview:hover,
.reference-preview:focus-visible {
  outline: 3px solid rgba(0, 107, 69, 0.18);
  outline-offset: 2px;
}

.reference-preview:hover span,
.reference-preview:focus-visible span {
  opacity: 1;
  transform: translateY(0);
}

.mockup-lightbox[hidden] {
  display: none;
}

.mockup-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.mockup-lightbox-backdrop {
  position: absolute;
  inset: 0;
  padding: 0;
  background: rgba(10, 21, 17, 0.78);
  border: 0;
}

.mockup-lightbox-frame {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(96vw, 1500px);
  max-height: 94vh;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.mockup-lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.mockup-lightbox-toolbar span {
  font-size: 15px;
  font-weight: 800;
}

.mockup-lightbox-toolbar .ghost-button {
  min-height: 48px;
  padding: 0 20px;
  touch-action: manipulation;
}

.mockup-lightbox-frame > img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: #f5f7f6;
}

@media (max-width: 1180px) {
  .builder-grid,
  .lower-grid {
    grid-template-columns: 1fr 1fr;
  }

  .workflow-panel {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    flex-wrap: wrap;
    padding: 16px;
  }

  .nav-links {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }

  .top-actions {
    margin-left: auto;
  }

  .app-shell {
    width: min(100% - 24px, 720px);
    margin-top: 12px;
  }

  .summary-band,
  .builder-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }

  .summary-band {
    display: grid;
    padding-top: 14px;
  }

  .proof-points {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 38px;
  }

  .workflow-canvas {
    min-height: 500px;
  }

  .node {
    width: min(190px, calc(100% - 24px));
  }
}
