/* =========================
   CONTRACT STUDIO V3 BASE
========================= */

.contract-studio-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 12%, rgba(8,196,100,0.12), transparent 30%),
    radial-gradient(circle at 88% 22%, rgba(195,143,72,0.13), transparent 34%),
    linear-gradient(135deg, #f7f1e5 0%, #f6f3ea 46%, #edf8ec 100%);
  color: var(--navy);
}

.studio-shell {
  padding: 112px 34px 34px;
}

.studio-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
  margin-bottom: 24px;
}

.studio-eyebrow {
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.studio-hero h1 {
  max-width: 840px;
  font-size: 3rem;
  line-height: 0.98;
  color: var(--navy);
  margin-bottom: 12px;
}

.studio-hero p {
  color: var(--muted);
  max-width: 760px;
  font-weight: 700;
}

.studio-back-btn {
  text-decoration: none;
  color: var(--navy);
  background: white;
  padding: 13px 18px;
  border-radius: 999px;
  font-weight: 900;
  box-shadow: 0 14px 34px rgba(20,50,92,0.08);
}

.studio-workspace {
  min-height: 690px;
  display: grid;
  grid-template-columns: 1.35fr 0fr 0.65fr;
  gap: 18px;
  transition: grid-template-columns 0.45s ease;
}

.studio-workspace.state-view,
.studio-workspace.state-edit,
.studio-workspace.state-new {
  grid-template-columns: 0.42fr 1.3fr 0.56fr;
}

.studio-panel {
  border-radius: 34px;
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(20,50,92,0.08);
  box-shadow: 0 24px 68px rgba(20,50,92,0.08);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.agreement-stream {
  padding: 0 32px 28px;
}

.studio-canvas {
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(18px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.state-view .studio-canvas,
.state-edit .studio-canvas,
.state-new .studio-canvas {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  padding: 26px;
}

.fit-preview {
  padding: 26px;
}

.stream-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.stream-head h2,
.studio-canvas h2,
.fit-preview h2 {
  color: var(--navy);
  line-height: 1.1;
}

.new-contract-btn,
.primary-studio-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--green);
  color: white;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(8,196,100,0.18);
}

.stream-filters {
  display: flex;
  gap: 8px;
  margin: 18px 0 20px;
  overflow-x: auto;
}

.stream-filters button {
  border: none;
  border-radius: 999px;
  padding: 10px 13px;
  background: rgba(20,50,92,0.07);
  color: var(--navy);
  font-weight: 900;
}

.stream-filters button.active {
  background: rgba(8,196,100,0.13);
  color: var(--green);
}

.contract-feed {
  display: grid;
  gap: 13px;
}

.contract-card {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 13px;
  padding: 16px;
  border-radius: 26px;
  background: rgba(248,248,240,0.88);
  border: 1px solid rgba(20,50,92,0.06);
  cursor: pointer;
  transition: all 0.25s ease;
}

.contract-card:hover,
.contract-card.selected {
  background: rgba(8,196,100,0.10);
  transform: translateY(-3px);
  box-shadow: 0 18px 38px rgba(20,50,92,0.09);
}

.contract-card h3 {
  color: var(--navy);
  line-height: 1.1;
}

.contract-card p,
.contract-card small {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.25;
}

.contract-card small {
  display: block;
  margin-top: 5px;
  font-size: 0.75rem;
}

.contract-card-meta {
  color: var(--green);
  font-weight: 900;
  font-size: 0.8rem;
}

.status-label {
  display: inline-flex;
  margin-bottom: 6px;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.status-label.review { color: #b68942; }
.status-label.pending { color: #8fa1b5; }
.status-label.draft { color: #4477d8; }
.status-label.accepted { color: var(--green); }

.status-marker {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  margin-top: 8px;
}

.status-marker.review {
  background: #d5a13d;
  box-shadow: 0 0 0 8px rgba(213,161,61,0.12);
}

.status-marker.pending { background: #8fa1b5; }
.status-marker.draft { background: #5d8ce6; }

.status-marker.accepted {
  background: var(--green);
  box-shadow: 0 0 0 8px rgba(8,196,100,0.12);
}

.contract-actions {
  grid-column: 2 / 4;
  display: none;
  gap: 9px;
  margin-top: 12px;
}

.contract-card.selected .contract-actions {
  display: flex;
}

.contract-actions button,
.soft-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 13px;
  background: rgba(20,50,92,0.08);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}

.contract-actions button:hover,
.soft-btn:hover {
  background: rgba(8,196,100,0.13);
  color: var(--green);
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #8fa1b5;
  animation: dotPulse 1.1s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.empty-canvas {
  height: 100%;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 40px;
}

.empty-canvas h2 {
  font-size: 2.2rem;
}

.empty-canvas p {
  color: var(--muted);
  max-width: 520px;
  margin-top: 10px;
}

.hidden {
  display: none !important;
}

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

.canvas-head p {
  color: var(--muted);
  font-weight: 700;
}

.review-alert {
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(213,161,61,0.12);
  border: 1px solid rgba(213,161,61,0.18);
  margin-bottom: 18px;
}

.review-alert strong {
  color: #8a6a2d;
  display: block;
}

.review-alert span {
  color: var(--muted);
  font-weight: 700;
}

.read-section,
.product-editor,
.contract-terms {
  padding: 22px;
  border-radius: 30px;
  background: rgba(255,255,255,0.64);
  border: 1px solid rgba(20,50,92,0.07);
  margin-bottom: 18px;
}

.read-section h3 {
  color: var(--navy);
  margin-bottom: 14px;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.compare-grid div {
  padding: 18px;
  border-radius: 22px;
  background: rgba(245,247,242,0.86);
}

.compare-grid div.changed {
  background: rgba(8,196,100,0.12);
  border: 1px solid rgba(8,196,100,0.18);
}

.compare-grid span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.compare-grid strong {
  display: block;
  color: var(--navy);
  margin: 8px 0 4px;
}

.compare-grid p,
.message-reference {
  color: var(--muted);
  font-weight: 800;
}

.product-row {
  padding: 18px 0;
  border-top: 1px solid rgba(20,50,92,0.08);
}

.product-row:first-child {
  border-top: none;
}

.product-summary {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--navy);
  font-weight: 900;
}

.product-summary span {
  color: var(--muted);
}

.product-fields {
  display: none;
  grid-template-columns: 1.4fr 1fr 1.4fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.product-row.active .product-fields {
  display: grid;
}

.product-fields label,
.contract-terms label {
  color: var(--navy);
  font-weight: 900;
  font-size: 0.83rem;
}

.product-fields input,
.product-fields select,
.contract-terms input,
.contract-terms select {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  border-radius: 17px;
  border: 1px solid rgba(20,50,92,0.11);
  background: #fffbf0;
  color: var(--navy);
  font-weight: 900;
  outline: none;
}

.product-fields select,
.contract-terms select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--navy) 50%),
    linear-gradient(135deg, var(--navy) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 55%,
    calc(100% - 12px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.split-field {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 8px;
}

.price-field {
  display: grid;
  grid-template-columns: 24px 1fr 34px 80px;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  padding: 0 10px;
  border-radius: 17px;
  border: 1px solid rgba(20,50,92,0.11);
  background: #fffbf0;
}

.price-field input,
.price-field select {
  margin-top: 0;
  border: none;
  background-color: transparent;
}

.price-field span,
.price-field small {
  color: var(--muted);
  font-weight: 900;
}

.add-row-btn {
  margin-top: 14px;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(8,196,100,0.12);
  color: var(--green);
  font-weight: 900;
}

.contract-terms {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.studio-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.fit-score {
  margin: 18px 0;
  padding: 22px;
  border-radius: 30px;
  color: white;
  background: linear-gradient(135deg, #17324f, #245236);
}

.fit-score span {
  color: var(--light-green);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.fit-score strong {
  display: block;
  font-size: 2.2rem;
  margin: 8px 0;
}

.fit-score p {
  color: rgba(255,255,255,0.72);
}

.fit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.fit-grid div {
  padding: 17px;
  border-radius: 22px;
  background: rgba(245,247,242,0.84);
}

.fit-grid span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.fit-grid strong {
  display: block;
  color: var(--navy);
  font-size: 1.45rem;
  margin-top: 6px;
}

.fit-note {
  margin-top: 14px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(8,196,100,0.10);
}

.fit-note strong {
  color: var(--navy);
}

.fit-note p {
  color: var(--muted);
  margin-top: 6px;
  font-weight: 700;
}

.final-review-modal {
  position: fixed;
  inset: 0;
  z-index: 7000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(245,247,242,0.64);
  backdrop-filter: blur(14px);
}

.final-review-modal.active {
  display: flex;
}

.final-review-card {
  width: min(560px, calc(100% - 32px));
  padding: 34px;
  border-radius: 34px;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 30px 90px rgba(20,50,92,0.18);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: rgba(20,50,92,0.08);
  color: var(--navy);
  font-size: 1.3rem;
  font-weight: 900;
}

.final-review-card h2 {
  color: var(--navy);
}

.final-review-card p {
  color: var(--muted);
  margin: 8px 0 18px;
}

.final-summary {
  display: grid;
  gap: 10px;
}

.final-summary div {
  display: flex;
  justify-content: space-between;
  padding: 14px;
  border-radius: 16px;
  background: rgba(245,247,242,0.82);
}

.final-summary span {
  color: var(--muted);
  font-weight: 900;
}

.final-summary strong {
  color: var(--navy);
}

@media (max-width: 1200px) {
  .studio-workspace,
  .studio-workspace.state-view,
  .studio-workspace.state-edit,
  .studio-workspace.state-new {
    grid-template-columns: 1fr;
  }

  .studio-canvas {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .product-fields,
  .contract-terms,
  .compare-grid,
  .fit-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   CONTRACT STUDIO V3 PATCH
========================= */

.studio-workspace {
  height: calc(100vh - 270px);
  min-height: 690px;
}

.studio-panel {
  max-height: 100%;
  overflow: hidden;
}

.left-panel,
.studio-canvas,
.fit-preview {
  overflow-y: auto;
}

.studio-workspace.state-stream {
  grid-template-columns: 1.35fr 0fr 0.65fr;
}

.studio-workspace.state-view,
.studio-workspace.state-edit,
.studio-workspace.state-new {
  grid-template-columns: 0.34fr 1.35fr 0.56fr;
}

.left-mode.hidden {
  display: none;
}

.context-mode {
  height: 100%;
}

.new-contract-row {
  width: 100%;
  border: none;
  margin: 18px 0 14px;
  padding: 13px 16px;
  border-radius: 999px;
  background: rgba(8,196,100,0.12);
  color: var(--green);
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.22s ease;
}

.new-contract-row span {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--green);
  color: white;
  display: grid;
  place-items: center;
}

.new-contract-row:hover {
  background: var(--green);
  color: white;
  transform: translateY(-2px);
}

.new-contract-row:hover span {
  background: white;
  color: var(--green);
}

.back-to-stream {
  border: none;
  border-radius: 999px;
  padding: 11px 14px;
  background: rgba(20,50,92,0.08);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
  margin-bottom: 18px;
}

.context-subtitle {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 18px;
}

.context-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(245,247,242,0.86);
  margin-bottom: 12px;
}

.context-card span,
.context-products span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.context-card strong {
  color: var(--navy);
}

.context-products {
  margin-top: 20px;
}

.context-products button {
  width: 100%;
  border: none;
  margin-bottom: 8px;
  padding: 11px 13px;
  border-radius: 999px;
  background: rgba(8,196,100,0.10);
  color: var(--green);
  font-weight: 900;
}

.receipt-section {
  padding: 22px;
  border-radius: 30px;
  background: rgba(255,255,255,0.66);
  border: 1px solid rgba(20,50,92,0.07);
  margin-bottom: 18px;
}

.receipt-section h3 {
  color: var(--navy);
  margin-bottom: 14px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid rgba(20,50,92,0.08);
}

.receipt-row strong {
  color: var(--navy);
}

.receipt-row span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.receipt-row em {
  font-style: normal;
  color: var(--green);
  font-weight: 900;
}

.receipt-total {
  display: flex;
  justify-content: space-between;
  padding-top: 16px;
}

.receipt-total span {
  color: var(--muted);
  font-weight: 900;
}

.receipt-total strong {
  color: var(--navy);
  font-size: 1.4rem;
}

.recipient-select {
  padding: 22px;
  border-radius: 30px;
  background: rgba(8,196,100,0.08);
  border: 1px solid rgba(8,196,100,0.12);
  margin-bottom: 18px;
}

.recipient-select h3 {
  color: var(--navy);
  margin-bottom: 14px;
}

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

.recipient-grid button {
  border: none;
  border-radius: 18px;
  padding: 14px;
  background: white;
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}

.recipient-grid button:hover {
  background: rgba(8,196,100,0.12);
  color: var(--green);
}

.remove-row-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(182,64,45,0.10);
  color: #b6402d;
  font-weight: 900;
  cursor: pointer;
}

.product-summary {
  align-items: center;
}

.product-summary button {
  justify-self: end;
}

.contract-document {
  max-height: 84vh;
  overflow-y: auto;
}

.document-note {
  color: var(--muted);
  margin-bottom: 18px;
}

.document-block {
  padding: 18px;
  border-radius: 20px;
  background: rgba(245,247,242,0.86);
  margin-bottom: 12px;
}

.document-block h3 {
  color: var(--navy);
  margin-bottom: 8px;
}

.document-block p {
  color: var(--muted);
  font-weight: 700;
}

.state-view .agreement-stream,
.state-edit .agreement-stream,
.state-new .agreement-stream {
  padding: 18px;
}

.state-view .stream-mode,
.state-edit .stream-mode,
.state-new .stream-mode {
  display: none;
}

.state-view .context-mode,
.state-edit .context-mode,
.state-new .context-mode {
  display: block;
}

@media (max-width: 1200px) {
  .studio-workspace {
    height: auto;
  }
}

/* =========================
   CONTRACT STUDIO V4 CLEANUP
========================= */

.studio-shell {
  padding: 96px 34px 28px;
}

.studio-hero {
  margin-bottom: 16px;
  align-items: center;
}

.studio-hero h1 {
  font-size: 2.35rem;
  line-height: 1.02;
  max-width: 720px;
}

.studio-hero p {
  max-width: 700px;
  font-size: 0.98rem;
}

.studio-workspace {
  height: calc(100vh - 220px);
  min-height: 640px;
  align-items: stretch;
}

.studio-panel {
  min-height: 0;
}

.left-panel,
.studio-canvas,
.right-panel {
  overflow-y: auto;
  scrollbar-width: thin;
}

.right-panel {
  padding: 26px;
}

.studio-workspace.state-stream {
  grid-template-columns: 1.28fr 0fr 0.72fr;
}

.studio-workspace.state-view,
.studio-workspace.state-edit,
.studio-workspace.state-new {
  grid-template-columns: 0.30fr 1.42fr 0.58fr;
}

.state-view .left-panel,
.state-edit .left-panel,
.state-new .left-panel {
  overflow-x: hidden;
}

.state-view .context-mode h2,
.state-edit .context-mode h2,
.state-new .context-mode h2 {
  font-size: 1.2rem;
  line-height: 1.1;
  word-break: normal;
}

.context-mode .studio-eyebrow,
.context-subtitle {
  font-size: 0.78rem;
}

.context-card {
  padding: 13px;
}

.context-products button {
  font-size: 0.78rem;
  padding: 10px;
}

.contract-card {
  min-height: 118px;
}

.contract-card-main h3 {
  font-size: 1.05rem;
}

.contract-card-main p {
  font-size: 0.88rem;
}

.contract-card.selected {
  border-color: rgba(8,196,100,0.18);
}

/* New contract row should be visible but not oversized */
.new-contract-row {
  min-height: 46px;
}

/* Canvas cleanup */
.state-view .studio-canvas,
.state-edit .studio-canvas,
.state-new .studio-canvas {
  padding: 28px;
}

.canvas-mode h2 {
  font-size: 1.75rem;
  line-height: 1.1;
}

.canvas-subtitle {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 18px;
}

.canvas-head {
  align-items: center;
}

/* Better product editor spacing */
.product-editor,
.contract-terms,
.receipt-section {
  background: rgba(255,255,255,0.78);
}

.product-row {
  border-top: 1px solid rgba(20,50,92,0.09);
  padding: 20px 0;
}

.product-row:first-child {
  border-top: none;
}

.product-summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
}

.product-summary strong {
  white-space: normal;
}

.product-summary span {
  white-space: nowrap;
}

.product-fields {
  grid-template-columns: minmax(180px, 1.25fr) minmax(150px, 0.85fr) minmax(220px, 1.2fr) minmax(150px, 0.8fr);
}

.product-fields select {
  min-width: 0;
}

.split-field {
  grid-template-columns: minmax(78px, 1fr) 90px;
}

.price-field {
  grid-template-columns: 22px minmax(70px, 1fr) 34px 86px;
}

.product-fields input[type="number"],
.contract-terms input[type="number"],
.price-field input {
  min-width: 0;
}

/* Right panel adaptive modes */
.right-mode.hidden,
.right-tab-panel.hidden {
  display: none !important;
}

.right-subtitle {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 16px;
}

.network-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 16px 0 12px;
}

.network-search input {
  width: 100%;
  border: 1px solid rgba(20,50,92,0.10);
  border-radius: 999px;
  padding: 12px 14px;
  background: rgba(255,252,245,0.92);
  color: var(--navy);
  font-weight: 800;
  outline: none;
}

.network-search button {
  border: none;
  border-radius: 999px;
  padding: 12px 14px;
  background: rgba(20,50,92,0.08);
  color: var(--navy);
  font-weight: 900;
}

.network-tabs,
.right-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.network-tabs button,
.right-toggle button {
  border: none;
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(20,50,92,0.08);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}

.network-tabs button.active,
.right-toggle button.active {
  background: rgba(8,196,100,0.14);
  color: var(--green);
}

.business-list {
  display: grid;
  gap: 10px;
  max-height: 255px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 16px;
}

.business-row {
  width: 100%;
  border: 1px solid rgba(20,50,92,0.06);
  border-radius: 20px;
  background: rgba(245,247,242,0.78);
  padding: 12px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 11px;
  text-align: left;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.business-row:hover,
.business-row.selected {
  background: rgba(8,196,100,0.10);
  border-color: rgba(8,196,100,0.16);
  transform: translateY(-2px);
}

.business-row strong {
  color: var(--navy);
  display: block;
}

.business-row small {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.25;
}

.business-logo {
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #17324f, #245236);
  color: white;
  font-weight: 900;
}

.small-logo {
  width: 42px;
  height: 42px;
  font-size: 0.8rem;
}

.large-logo {
  width: 62px;
  height: 62px;
  font-size: 1rem;
}

.green-logo {
  background: linear-gradient(135deg, #08c464, #7ddc49);
}

.business-preview {
  padding: 18px;
  border-radius: 26px;
  background:
    radial-gradient(circle at top right, rgba(8,196,100,0.14), transparent 40%),
    rgba(255,255,255,0.82);
  border: 1px solid rgba(20,50,92,0.07);
}

.business-preview-head {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.business-preview-head span:not(.business-logo) {
  color: var(--muted);
  font-weight: 900;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.business-preview h3 {
  color: var(--navy);
  line-height: 1.1;
}

.business-preview p {
  color: var(--muted);
  font-weight: 700;
}

.preview-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.preview-stats div {
  padding: 12px;
  border-radius: 18px;
  background: rgba(245,247,242,0.86);
}

.preview-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.preview-stats strong {
  color: var(--navy);
  display: block;
  margin-top: 4px;
  font-size: 0.86rem;
}

.preview-note {
  padding: 13px;
  border-radius: 18px;
  background: rgba(8,196,100,0.09);
  margin-bottom: 14px;
}

.preview-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.preview-actions .primary-studio-btn,
.preview-actions .soft-btn {
  padding: 10px 12px;
  font-size: 0.82rem;
}

/* Agreement snapshot */
.snapshot-alert {
  padding: 18px;
  border-radius: 24px;
  background: rgba(213,161,61,0.12);
  border: 1px solid rgba(213,161,61,0.18);
  margin: 16px 0;
}

.snapshot-alert span {
  color: #8a6a2d;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.snapshot-alert strong {
  display: block;
  color: var(--navy);
  font-size: 1.35rem;
  margin: 6px 0;
}

.snapshot-alert p {
  color: var(--muted);
  font-weight: 700;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.snapshot-grid div {
  padding: 15px;
  border-radius: 20px;
  background: rgba(245,247,242,0.84);
}

.snapshot-grid span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.snapshot-grid strong {
  display: block;
  color: var(--navy);
  margin-top: 4px;
}

.snapshot-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Products tab */
.profile-product-list {
  display: grid;
  gap: 11px;
  max-height: 430px;
  overflow-y: auto;
  padding-right: 4px;
}

.profile-product {
  width: 100%;
  border: 1px solid rgba(20,50,92,0.07);
  border-radius: 20px;
  background: rgba(255,252,245,0.88);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-product:hover {
  background: rgba(8,196,100,0.10);
  transform: translateY(-2px);
}

.profile-product strong {
  color: var(--navy);
  display: block;
}

.profile-product span {
  color: var(--muted);
  font-weight: 700;
}

.profile-product em {
  font-style: normal;
  color: var(--green);
  font-weight: 900;
}

/* Make final review feel more document-like */
.contract-document {
  width: min(720px, calc(100% - 36px));
}

.document-block {
  border-left: 4px solid rgba(8,196,100,0.35);
}

/* Responsive */
@media (max-width: 1200px) {
  .studio-shell {
    padding-top: 96px;
  }

  .studio-hero h1 {
    font-size: 2rem;
  }

  .studio-workspace,
  .studio-workspace.state-view,
  .studio-workspace.state-edit,
  .studio-workspace.state-new {
    height: auto;
    grid-template-columns: 1fr;
  }

  .business-list,
  .profile-product-list {
    max-height: none;
  }
}

.finder-pulse {
  animation: finderPulse 0.95s ease;
}

/* Mini Animation */
@keyframes finderPulse {
  0% {
    box-shadow: 0 0 0 rgba(8,196,100,0);
  }

  35% {
    box-shadow: 0 0 0 8px rgba(8,196,100,0.10);
  }

  100% {
    box-shadow: 0 0 0 rgba(8,196,100,0);
  }
}

/* =========================
   CONTRACT STUDIO V5 POLISH
========================= */

/* Give the app room and prevent hero/workspace collision */
.studio-shell {
  padding: 92px 34px 28px;
}

.studio-hero {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
}

.studio-hero h1 {
  font-size: 2.15rem;
  line-height: 1.05;
  max-width: 720px;
}

.studio-hero p {
  max-width: 680px;
  line-height: 1.45;
}

.studio-workspace {
  height: calc(100vh - 215px);
  min-height: 660px;
}

/* Make main workspace panels breathe more */
.studio-canvas,
.right-panel {
  padding-top: 28px;
}

/* Keep the Agreement Stream banner attached to the top of its panel */
.left-panel.agreement-stream {
  padding-top: 0;
}

/* Older compact stream title styling disabled for Agreement Stream banner */
/* .stream-head {
  padding: 0 2px 4px;
  margin-bottom: 4px;
} */

.stream-head .studio-eyebrow {
  color: var(--green);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.stream-head h2 {
  font-size: 1.55rem;
  line-height: 1.12;
  margin-top: 6px;
}

/* Prevent panel title/borders from visually colliding */
.agreement-stream,
.left-panel {
  position: relative;
}

/* Cleaner contract stream cards */
.contract-feed {
  padding-top: 8px;
}

.contract-card {
  min-height: unset;
  padding: 20px;
  border-radius: 28px;
}

.contract-card-main h3 {
  font-size: 1.15rem;
  line-height: 1.15;
  margin-bottom: 3px;
}

.contract-card-main p {
  line-height: 1.35;
}

.contract-actions {
  padding-top: 4px;
}

.contract-actions button {
  min-width: 76px;
}

/* Stronger left panel title area */
.stream-filters {
  padding-bottom: 4px;
}

.stream-filters button {
  padding: 10px 15px;
}

/* When collapsed, don't cram long text */
.state-view .left-panel,
.state-edit .left-panel,
.state-new .left-panel {
  padding: 22px 14px;
}

.state-view .context-mode h2,
.state-edit .context-mode h2,
.state-new .context-mode h2 {
  font-size: 1.15rem;
  line-height: 1.16;
}

.state-view .context-subtitle,
.state-edit .context-subtitle,
.state-new .context-subtitle {
  font-size: 0.82rem;
  line-height: 1.35;
}

.state-view .context-card,
.state-edit .context-card,
.state-new .context-card {
  padding: 13px;
  border-radius: 18px;
}

.state-view .context-products button,
.state-edit .context-products button,
.state-new .context-products button {
  white-space: normal;
  line-height: 1.15;
}

/* Right network profile subviews */
.network-subview.hidden {
  display: none !important;
}

.network-helper {
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(8,196,100,0.08);
  color: var(--muted);
  font-weight: 800;
  line-height: 1.4;
}

.back-to-network {
  border: none;
  border-radius: 999px;
  padding: 11px 14px;
  background: rgba(20,50,92,0.08);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
  margin-bottom: 18px;
}

.profile-mini-hero {
  padding: 18px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(8,196,100,0.16), transparent 42%),
    rgba(255,255,255,0.82);
  border: 1px solid rgba(20,50,92,0.08);
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 15px;
  align-items: center;
  margin-bottom: 14px;
}

.profile-mini-hero .large-logo {
  width: 70px;
  height: 70px;
}

.profile-mini-hero span:not(.business-logo) {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.profile-mini-hero h3 {
  color: var(--navy);
  font-size: 1.45rem;
  line-height: 1.08;
  margin: 4px 0;
}

.profile-mini-hero p {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.profile-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.profile-stat-grid div {
  padding: 14px;
  border-radius: 20px;
  background: rgba(245,247,242,0.86);
}

.profile-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}

.profile-stat-grid strong {
  color: var(--navy);
  font-size: 0.92rem;
}

.profile-insight {
  padding: 16px;
  border-radius: 22px;
  background: rgba(8,196,100,0.09);
  border: 1px solid rgba(8,196,100,0.10);
  margin-bottom: 16px;
}

.profile-insight span {
  display: block;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.profile-insight strong {
  color: var(--navy);
  font-size: 1rem;
  line-height: 1.35;
}

.profile-products-section {
  margin-top: 12px;
}

.profile-products-head {
  margin-bottom: 10px;
}

.profile-products-head .studio-eyebrow {
  margin-bottom: 2px;
}

.profile-products-head small {
  color: var(--muted);
  font-weight: 800;
}

.profile-product-list.compact {
  max-height: 275px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}

.profile-product-list.compact .profile-product {
  border-radius: 20px;
  padding: 14px;
  min-height: 72px;
}

.profile-product-list.compact .profile-product strong {
  font-size: 0.95rem;
  line-height: 1.15;
}

.profile-product-list.compact .profile-product span {
  font-size: 0.82rem;
  line-height: 1.25;
}

.sticky-profile-actions {
  position: sticky;
  bottom: 0;
  padding-top: 14px;
  margin-top: 14px;
  background: linear-gradient(
    to top,
    rgba(255,255,255,0.96),
    rgba(255,255,255,0.74),
    transparent
  );
}

/* Right panel should feel like a self-contained tab */
.right-panel {
  padding: 28px;
}

.right-panel h2 {
  font-size: 1.55rem;
  line-height: 1.12;
}

/* Improve business rows */
.business-list {
  max-height: 330px;
}

.business-row {
  min-height: 70px;
}

.business-row strong {
  font-size: 0.95rem;
}

.business-row small {
  font-size: 0.78rem;
}

/* Product editor fields should not hide text */
.product-fields {
  grid-template-columns:
    minmax(210px, 1.35fr)
    minmax(160px, 0.9fr)
    minmax(250px, 1.25fr)
    minmax(160px, 0.9fr);
}

.product-fields label {
  min-width: 0;
}

.product-fields select,
.product-fields input {
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-summary {
  gap: 16px;
}

/* Make final-review overlay feel less empty */
.final-review-card {
  transform: translateY(-2vh);
}

/* Mobile/tablet safety */
@media (max-width: 1200px) {
  .studio-hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .studio-workspace {
    height: auto;
  }

  .profile-product-list.compact {
    max-height: none;
  }
}

/* =========================
   CONTRACT STUDIO V6 — STREAM HEADER + NEW FLOW
========================= */

.stream-head .studio-eyebrow {
  color: var(--green);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  margin-bottom: 8px;
}

.stream-head h2 {
  color: var(--navy);
  font-size: 1.6rem;
  line-height: 1.08;
  margin: 0;
}

.stream-intro-note {
  margin-top: 10px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.35;
  font-size: 0.9rem;
}

/* The new-contract row should feel like a guided action, not a random bar */
.new-contract-row {
  justify-content: flex-start;
  min-height: 54px;
  padding: 14px 18px;
  margin: 0 0 18px;
  box-shadow: 0 14px 28px rgba(8,196,100,0.08);
}

.new-contract-row strong {
  font-size: 0.95rem;
}

.new-contract-row small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  margin-top: 2px;
}

.new-contract-row:hover small {
  color: rgba(255,255,255,0.84);
}

/* Prevent top content from feeling hidden behind panel borders */
.studio-workspace {
  padding-top: 0;
}

.left-panel,
.studio-canvas,
.right-panel {
  scroll-padding-top: 24px;
}

/* Editor guidance state */
.blank-contract-guidance {
  padding: 24px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(8,196,100,0.13), transparent 38%),
    rgba(255,255,255,0.82);
  border: 1px dashed rgba(8,196,100,0.26);
  margin-bottom: 18px;
}

.blank-contract-guidance h3 {
  color: var(--navy);
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.blank-contract-guidance p {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.4;
}

/* Blank editor state */
.product-editor.is-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  border-style: dashed;
  border-color: rgba(8,196,100,0.22);
  background: rgba(8,196,100,0.045);
}

.product-editor.is-empty .empty-product-message {
  text-align: center;
  max-width: 420px;
}

.empty-product-message strong {
  display: block;
  color: var(--navy);
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.empty-product-message span {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.4;
}

/* Right-side business finder highlight */
.network-mode.finder-focus {
  animation: finderFocus 1.2s ease;
}

@keyframes finderFocus {
  0% {
    box-shadow: 0 0 0 0 rgba(8,196,100,0);
  }

  35% {
    box-shadow: 0 0 0 10px rgba(8,196,100,0.12);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(8,196,100,0);
  }
}

/* Make right panel product list show more items without feeling cramped */
.profile-product-list.compact,
.profile-product-list {
  max-height: 420px;
}

.work-panel-mode .profile-product-list {
  max-height: 520px;
}

/* Product row polish */
.product-editor {
  overflow-x: hidden;
}

.product-row {
  width: 100%;
}

.product-row:not(.active) .product-fields {
  display: none;
}

.product-row:not(.active) {
  cursor: pointer;
}

.product-row:not(.active):hover {
  background: rgba(8,196,100,0.035);
}

.product-summary {
  min-height: 48px;
}

/* =========================
   CONTRACT STUDIO V6.1 — EMPTY CONTRACT FIX
========================= */

.product-editor.is-empty {
  display: block;
  min-height: 260px;
  padding: 28px;
  border: 1px dashed rgba(8,196,100,0.28);
  background:
    radial-gradient(circle at top right, rgba(8,196,100,0.10), transparent 38%),
    rgba(255,255,255,0.74);
}

.product-editor.is-empty .empty-product-message {
  padding: 32px 24px;
  border-radius: 26px;
  background: rgba(8,196,100,0.07);
  text-align: center;
  margin-bottom: 22px;
}

.product-editor.is-empty .empty-product-message strong {
  display: block;
  color: var(--navy);
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.product-editor.is-empty .empty-product-message span {
  display: block;
  max-width: 460px;
  margin: 0 auto;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.product-editor.is-empty #addProductRow {
  margin: 0 auto;
  display: inline-flex;
}

.blank-contract-guidance {
  display: block;
}

.blank-contract-guidance.hidden {
  display: none;
}

/* =========================
   CONTRACT STUDIO — AGREEMENT STREAM HEADER CLEANUP
========================= */

.contract-studio-page .studio-panel.left-panel.agreement-stream {
  padding: 0 32px 28px;
  overflow-y: auto;
  overflow-x: hidden;
}

.contract-studio-page .agreement-stream .stream-head {
  margin: 0 -32px 28px;
  padding: 34px 38px 30px;
  border-radius: 34px 34px 18px 18px;
  background: linear-gradient(135deg, #0f5f43 0%, #14945b 100%);
  border: 1px solid rgba(18, 114, 77, 0.22);
  box-shadow:
    0 18px 34px rgba(18, 114, 77, 0.14),
    inset 0 1px 0 rgba(255,255,255,0.13);
  position: relative;
  overflow: hidden;
}

.contract-studio-page .agreement-stream .stream-head::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.16), transparent 34%),
    linear-gradient(135deg, rgba(255,255,255,0.08), transparent 42%);
  pointer-events: none;
}

.contract-studio-page .agreement-stream .stream-head > div {
  position: relative;
  z-index: 1;
}

.contract-studio-page .agreement-stream .stream-head .studio-eyebrow {
  color: #c8f7d8;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.contract-studio-page .agreement-stream .stream-head h2 {
  color: #f8fff9;
  font-size: 2rem;
  line-height: 1.08;
  font-weight: 900;
  margin: 0 0 12px;
}

.contract-studio-page .agreement-stream .stream-intro-note {
  color: rgba(248, 255, 249, 0.84);
  font-size: 0.98rem;
  line-height: 1.5;
  font-weight: 750;
  max-width: 760px;
  margin: 0;
}

/* =========================
   CONTRACT STUDIO — FOCUS MODE
   Hide left stream panel while viewing/editing/building contracts
========================= */

.contract-studio-page .studio-workspace.state-view,
.contract-studio-page .studio-workspace.state-edit,
.contract-studio-page .studio-workspace.state-new {
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.55fr);
}

.contract-studio-page .studio-workspace.state-view .left-panel,
.contract-studio-page .studio-workspace.state-edit .left-panel,
.contract-studio-page .studio-workspace.state-new .left-panel {
  display: none;
}

.contract-studio-page .studio-workspace.state-view .studio-canvas,
.contract-studio-page .studio-workspace.state-edit .studio-canvas,
.contract-studio-page .studio-workspace.state-new .studio-canvas {
  padding: 34px;
}

.contract-studio-page .studio-workspace.state-view .right-panel,
.contract-studio-page .studio-workspace.state-edit .right-panel,
.contract-studio-page .studio-workspace.state-new .right-panel {
  padding: 30px;
}

/* =========================
   CONTRACT BUILDER — FLEXIBLE AGREEMENT TEMPLATE
========================= */

.agreement-builder-hero {
  margin-bottom: 22px;
  padding: 30px;
  border-radius: 32px;
  background: linear-gradient(135deg, #0f5f43 0%, #14945b 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: flex-start;
  box-shadow:
    0 18px 34px rgba(18, 114, 77, 0.14),
    inset 0 1px 0 rgba(255,255,255,0.13);
  position: relative;
  overflow: hidden;
}

.agreement-builder-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.16), transparent 34%),
    linear-gradient(135deg, rgba(255,255,255,0.08), transparent 42%);
  pointer-events: none;
}

.agreement-builder-hero > * {
  position: relative;
  z-index: 1;
}

.agreement-builder-hero .studio-eyebrow {
  color: #c8f7d8;
}

.agreement-builder-hero h2 {
  color: #f8fff9;
  font-size: 2rem;
  line-height: 1.08;
  margin-bottom: 10px;
}

.agreement-builder-hero .canvas-subtitle {
  color: rgba(248,255,249,0.82);
  margin: 0;
}

.builder-status-pill {
  min-width: 170px;
  padding: 14px 16px;
  border-radius: 22px;
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.16);
}

.builder-status-pill span {
  display: block;
  color: rgba(248,255,249,0.72);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.builder-status-pill strong {
  color: white;
  font-size: 0.95rem;
}

.builder-section {
  padding: 24px;
  border-radius: 30px;
  background: rgba(255,255,255,0.76);
  border: 1px solid rgba(20,50,92,0.07);
  margin-bottom: 18px;
}

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

.builder-section-head h3 {
  color: var(--navy);
  font-size: 1.35rem;
  line-height: 1.12;
  margin-bottom: 5px;
}

.builder-section-head p {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.42;
  max-width: 720px;
}

.section-status {
  white-space: nowrap;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 900;
}

.section-status.complete {
  background: rgba(8,196,100,0.12);
  color: var(--green);
}

.section-status.needs-input {
  background: rgba(213,161,61,0.14);
  color: #9b762f;
}

.section-status.optional {
  background: rgba(20,50,92,0.08);
  color: var(--muted);
}

.agreement-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.agreement-type-card {
  border: 1px solid rgba(20,50,92,0.08);
  border-radius: 24px;
  background: rgba(255,252,245,0.86);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  transition: all 0.22s ease;
}

.agreement-type-card:hover {
  transform: translateY(-2px);
  background: rgba(8,196,100,0.08);
  border-color: rgba(8,196,100,0.18);
}

.agreement-type-card.active {
  background:
    radial-gradient(circle at top right, rgba(8,196,100,0.14), transparent 40%),
    rgba(232,248,235,0.92);
  border-color: rgba(8,196,100,0.30);
  box-shadow: 0 16px 32px rgba(8,196,100,0.10);
}

.agreement-type-card span {
  display: inline-flex;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.agreement-type-card strong {
  display: block;
  color: var(--navy);
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.agreement-type-card p {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.35;
}

.builder-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 14px;
}

.builder-field-grid label,
.-terms-box,
.flexible-product-fields label {
  color: var(--navy);
  font-weight: 900;
  font-size: 0.83rem;
}

.builder-field-grid input,
.builder-field-grid select,
.builder-field-grid textarea,
.custom-terms-box textarea,
.flexible-product-fields textarea {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  border-radius: 17px;
  border: 1px solid rgba(20,50,92,0.11);
  background: #fffbf0;
  color: var(--navy);
  font-weight: 850;
  outline: none;
}

.builder-field-grid textarea,
.custom-terms-box textarea,
.flexible-product-fields textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.4;
}

.wide-field {
  grid-column: 1 / -1;
}

.product-summary {
  grid-template-columns: 1fr auto;
}

.product-summary strong {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.organic-badge,
.conventional-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 0.64rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.organic-badge {
  color: #0f7a48;
  background: rgba(8,196,100,0.14);
  border: 1px solid rgba(8,196,100,0.18);
}

.conventional-badge {
  color: var(--muted);
  background: rgba(20,50,92,0.08);
  border: 1px solid rgba(20,50,92,0.08);
}

.flexible-product-fields {
  grid-template-columns:
    minmax(210px, 1.15fr)
    minmax(160px, 0.8fr)
    minmax(230px, 1fr)
    minmax(220px, 1fr);
}

.standard-terms-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.standard-term-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(245,247,242,0.82);
  border: 1px solid rgba(20,50,92,0.06);
}

.standard-term-card span {
  display: block;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.standard-term-card strong {
  display: block;
  color: var(--navy);
  margin-bottom: 6px;
}

.standard-term-card p {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.4;
  margin-bottom: 12px;
}

.standard-term-card button {
  border: none;
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(20,50,92,0.08);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}

.custom-terms-box {
  display: block;
}

/* =========================
   CONTRACT BUILDER — CUSTOM CLAUSES
========================= */

.custom-clause-list {
  display: grid;
  gap: 14px;
}

.custom-clause-card {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(20, 50, 92, 0.10);
  background:
    radial-gradient(circle at top right, rgba(8, 196, 100, 0.08), transparent 38%),
    rgba(255, 255, 255, 0.72);
}

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

.custom-clause-head strong {
  color: var(--navy);
  font-size: 0.95rem;
}

.remove-custom-clause {
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(160, 40, 30, 0.08);
  color: #9b2f24;
  font-weight: 900;
  cursor: pointer;
}

.custom-clause-card label {
  display: grid;
  gap: 8px;
  color: var(--navy);
  font-weight: 900;
  font-size: 0.84rem;
  margin-bottom: 12px;
}

.custom-clause-card input,
.custom-clause-card textarea {
  width: 100%;
  border: 1px solid rgba(20, 50, 92, 0.14);
  border-radius: 18px;
  background: rgba(250, 247, 238, 0.82);
  color: var(--navy);
  font: inherit;
  font-weight: 750;
  padding: 14px 16px;
  outline: none;
}

.custom-clause-card textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

.custom-clause-card input:focus,
.custom-clause-card textarea:focus {
  border-color: rgba(8, 196, 100, 0.42);
  box-shadow: 0 0 0 4px rgba(8, 196, 100, 0.08);
}

.add-custom-clause-btn {
  margin-top: 14px;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(8, 196, 100, 0.10);
  color: var(--green);
  font-weight: 950;
  cursor: pointer;
}


.sticky-builder-actions {
  position: sticky;
  bottom: 0;
  padding: 16px 0 4px;
  background: linear-gradient(
    to top,
    rgba(255,255,255,0.96),
    rgba(255,255,255,0.74),
    transparent
  );
  z-index: 5;
}

/* Focus mode: contract editor gets full breathing room */
.contract-studio-page .studio-workspace.state-view,
.contract-studio-page .studio-workspace.state-edit,
.contract-studio-page .studio-workspace.state-new {
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.55fr);
}

.contract-studio-page .studio-workspace.state-view .left-panel,
.contract-studio-page .studio-workspace.state-edit .left-panel,
.contract-studio-page .studio-workspace.state-new .left-panel {
  display: none;
}

@media (max-width: 1200px) {
  .agreement-builder-hero,
  .builder-section-head {
    display: block;
  }

  .builder-status-pill {
    margin-top: 16px;
  }

  .agreement-type-grid,
  .builder-field-grid,
  .standard-terms-grid,
  .flexible-product-fields {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }
}

/* =========================
   CONTRACT BUILDER — ACTION BUTTON CLEANUP
========================= */

/* Main builder buttons should sit naturally at the bottom of the contract form */
.sticky-builder-actions {
  position: static;
  padding: 18px 0 0;
  background: transparent;
  box-shadow: none;
}

/* Right profile action buttons should not cover profile/product content */
.sticky-profile-actions {
  position: static;
  padding-top: 16px;
  margin-top: 16px;
  background: transparent;
  border-top: 1px solid rgba(20,50,92,0.08);
}

/* Add an immediate recipient selector near the profile header */
.profile-mini-hero {
  grid-template-columns: 70px 1fr;
}

.profile-top-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.profile-select-btn {
  border: none;
  border-radius: 999px;
  padding: 11px 15px;
  background: var(--green);
  color: white;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(8,196,100,0.16);
}

.profile-select-btn:hover {
  transform: translateY(-1px);
}

.profile-secondary-btn {
  border: none;
  border-radius: 999px;
  padding: 11px 15px;
  background: rgba(20,50,92,0.08);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}

/* =========================
   CONTRACT STUDIO — COMPACT TOOL HEADER
========================= */

.contract-studio-page {
  overflow: hidden;
}

.studio-shell {
  height: 100vh;
  padding: 86px 30px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.compact-studio-hero {
  flex: 0 0 auto;
  margin-bottom: 14px;
  display: block;
  max-width: 920px;
}

.studio-title-lockup {
  padding: 0;
  margin-bottom: 6px;
}

.studio-title-lockup .studio-eyebrow {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.studio-title-lockup h1 {
  color: var(--navy);
  font-size: 2rem;
  line-height: 0.98;
  margin: 0;
}

.studio-hero-copy {
  max-width: 820px;
  padding: 0;
}

.studio-hero-copy h2 {
  color: var(--navy);
  font-size: 1.2rem;
  line-height: 1.12;
  margin: 0 0 5px;
  font-weight: 900;
}

.studio-hero-copy p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.32;
  font-weight: 750;
  margin: 0;
  max-width: 760px;
}

.studio-back-btn {
  display: none;
}

.studio-workspace {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.studio-panel {
  max-height: 100%;
  min-height: 0;
}

.left-panel,
.studio-canvas,
.right-panel {
  max-height: 100%;
  overflow-y: auto;
}

@media (max-width: 1100px) {
  .studio-title-lockup h1 {
    font-size: 1.8rem;
  }

  .studio-hero-copy h2 {
    font-size: 1.08rem;
  }
}

/* =========================
   CONTRACT STUDIO — LOADING SCREEN
========================= */

.contract-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(8,196,100,0.12), transparent 28%),
    linear-gradient(135deg, #f7f1e5 0%, #f6f3ea 48%, #edf8ec 100%);
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.contract-loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.contract-loading-card {
  text-align: center;
  animation: loadingCardIn 0.7s ease both;
}

.contract-loading-card img {
  width: 128px;
  margin-bottom: 14px;
}

.contract-loading-card p {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.contract-loading-card h2 {
  color: var(--navy);
  font-size: 2.15rem;
  line-height: 1;
  margin-bottom: 8px;
}

.contract-loading-card strong {
  display: block;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 850;
  margin-bottom: 18px;
}

.contract-loading-card span {
  display: block;
  color: var(--muted);
  font-weight: 850;
  margin-top: 14px;
}

.contract-loading-ring {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 999px;
  border: 4px solid rgba(8,196,100,0.16);
  border-top-color: var(--green);
  animation: loadingSpin 0.9s linear infinite;
}

@keyframes loadingSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loadingCardIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Page entrance after loading screen */
.contract-studio-page .studio-hero,
.contract-studio-page .studio-workspace {
  opacity: 0;
  transform: translateY(12px);
}

.contract-studio-page.studio-loaded .studio-hero {
  animation: studioIntro 0.65s ease forwards;
}

.contract-studio-page.studio-loaded .studio-workspace {
  animation: studioIntro 0.75s ease 0.12s forwards;
}

@keyframes studioIntro {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================
   CONTRACT STUDIO — REVIEW WAITING OVERLAY
========================= */

.review-waiting-overlay {
  position: fixed;
  inset: 0;
  z-index: 7000;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(15, 35, 30, 0.28);
  backdrop-filter: blur(8px);
}

body.review-tab-open .review-waiting-overlay {
  display: grid;
}

.review-waiting-card {
  width: min(520px, 100%);
  padding: 34px;
  border-radius: 34px;
  background:
    radial-gradient(circle at top right, rgba(8,196,100,0.12), transparent 36%),
    rgba(255, 252, 245, 0.96);
  border: 1px solid rgba(20,50,92,0.10);
  box-shadow: 0 28px 90px rgba(20,50,92,0.18);
  text-align: center;
}

.review-waiting-card h2 {
  color: var(--navy);
  font-size: 1.7rem;
  line-height: 1.08;
  margin: 8px 0 10px;
}

.review-waiting-card p {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.review-waiting-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* =========================
   CONTRACT STUDIO — SUBMITTED CARD SWEEP
========================= */

.contract-card.submitted-highlight {
  position: relative;
  overflow: hidden;
  border-color: rgba(8,196,100,0.34);
  box-shadow:
    0 0 0 1px rgba(8,196,100,0.16),
    0 24px 54px rgba(8,196,100,0.13);
  animation: submittedCardEnter 0.65s ease both;
}

.contract-card.submitted-highlight::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(8,196,100,0.10) 38%,
    rgba(255,255,255,0.34) 50%,
    rgba(8,196,100,0.10) 62%,
    transparent 100%
  );
  transform: translateX(-110%);
  animation: submittedSweep 1.15s ease 0.25s forwards;
  pointer-events: none;
}

@keyframes submittedCardEnter {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes submittedSweep {
  to {
    transform: translateX(110%);
  }
}

.status-dot.green {
  background: var(--green);
  box-shadow: 0 0 0 8px rgba(8, 196, 100, 0.12);
}

/* =========================
   CONTRACT STUDIO — SUBMITTED AGREEMENT CARD FINAL
========================= */

.submitted-agreement-card {
  display: block !important;
  width: 100% !important;
  min-height: unset !important;
  padding: 28px 32px !important;
  border-radius: 28px !important;
  background:
    radial-gradient(circle at top right, rgba(8, 196, 100, 0.10), transparent 34%),
    rgba(245, 252, 246, 0.92) !important;
  border: 1px solid rgba(8, 196, 100, 0.28) !important;
  overflow: hidden !important;
}

.submitted-card-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  margin-bottom: 14px !important;
}

.submitted-card-status {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
  color: var(--green) !important;
  font-size: 0.82rem !important;
  font-weight: 950 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
}

.submitted-card-dot {
  width: 12px !important;
  height: 12px !important;
  border-radius: 999px !important;
  background: var(--green) !important;
  box-shadow: 0 0 0 8px rgba(8, 196, 100, 0.14) !important;
  flex: 0 0 auto !important;
}

.submitted-card-header strong {
  color: var(--green) !important;
  font-weight: 950 !important;
  font-size: 0.95rem !important;
}

.submitted-card-body h3 {
  color: var(--navy) !important;
  font-size: 1.55rem !important;
  line-height: 1.1 !important;
  margin: 0 0 7px !important;
}

.submitted-card-body p {
  color: var(--muted) !important;
  font-weight: 850 !important;
  font-size: 1rem !important;
  margin: 0 0 8px !important;
}

.submitted-card-body small {
  display: block !important;
  color: var(--muted) !important;
  font-weight: 850 !important;
  font-size: 0.88rem !important;
  line-height: 1.35 !important;
  white-space: normal !important;
}

.submitted-card-actions {
  display: flex !important;
  gap: 10px !important;
  margin-top: 22px !important;
}

.submitted-card-actions button {
  border: none !important;
  border-radius: 999px !important;
  padding: 10px 18px !important;
  background: rgba(20, 50, 92, 0.08) !important;
  color: var(--navy) !important;
  font-weight: 950 !important;
  cursor: pointer !important;
}

.submitted-agreement-card.submitted-highlight {
  box-shadow:
    0 0 0 2px rgba(8, 196, 100, 0.22),
    0 26px 70px rgba(8, 196, 100, 0.22) !important;
  animation: submittedCardEnterStrong 0.8s ease both;
}

.submitted-agreement-card.submitted-highlight::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(8, 196, 100, 0.16) 32%,
    rgba(255, 255, 255, 0.62) 50%,
    rgba(8, 196, 100, 0.18) 68%,
    transparent 100%
  );
  transform: translateX(-115%);
  animation: submittedSweepStrong 2.25s ease 0.45s forwards;
  pointer-events: none;
}

@keyframes submittedCardEnterStrong {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes submittedSweepStrong {
  to {
    transform: translateX(115%);
  }
}

/* =========================
   PRODUCT ADD FEEDBACK
========================= */

.profile-product.just-added {
  background: rgba(8, 196, 100, 0.14);
  border-color: rgba(8, 196, 100, 0.34);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 14px 28px rgba(8, 196, 100, 0.13);
}

.profile-product.just-added em {
  color: var(--green);
  font-weight: 950;
}

.profile-product.add-click-pop {
  animation: productAddPop 0.28s ease;
}

@keyframes productAddPop {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(0.975);
  }

  100% {
    transform: scale(1.01);
  }
}
