:root {
  --primary: #1e6fea;
  --primary-hover: #1858c7;
  --navy: #1b2a4a;
  --navy-deep: #141f36;
  --green: #5bc236;
  --border: #e2e8f0;
  --card: #fff;
  --text: #1b2a4a;
  --muted: #64748b;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --copy-hover-bg: #f1f5f9;
  --cost-highlight-bg: #ecfdf5;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(
    135deg,
    #dbeafe 0%,
    #f8fafc 40%,
    #dcfce7 100%
  );
  background-attachment: fixed;
  min-height: 100vh;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--space-2) 2rem;
}

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 20px;
  margin-bottom: 14px;
  padding: 0;
  text-align: center;
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0;
  text-align: left;
}

.logo {
  height: 64px;
  width: auto;
  max-width: none;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  opacity: 1;
  mix-blend-mode: normal;
  image-rendering: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateY(2px);
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.scopeadd-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.brand-text .tagline {
  margin: 0;
  margin-top: 2px;
  padding: 0;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  color: #6b7280;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

.modal-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 24px 28px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(27, 42, 74, 0.12);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  margin: 0;
  padding: 4px 10px;
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--navy);
}

.modal-title {
  margin: 0 28px 14px 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--navy);
}

.modal-steps {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
}

.modal-steps li {
  margin-bottom: 8px;
}

.modal-steps li:last-child {
  margin-bottom: 0;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(27, 42, 74, 0.04);
}

.card-title {
  margin: 0 0 var(--space-2);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}

.inputs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}

.inputs-header .card-title {
  margin: 0;
}

.help-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: #64748b;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.help-btn:hover {
  color: #334155;
}

label {
  display: block;
  margin-top: var(--space-2);
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--navy);
}

label:first-of-type {
  margin-top: 0;
}

.form-field {
  margin-top: var(--space-2);
}

.form-card form > .form-field:first-of-type {
  margin-top: 0;
}

.form-field label {
  margin-top: 0;
}

.req {
  color: var(--error-text);
}

.input-error {
  border: 1px solid #ef4444 !important;
  background: #fef2f2;
}

.input-error:focus {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.field-error {
  margin: 4px 0 0;
  font-size: 12px;
  color: #ef4444;
  line-height: 1.4;
}

textarea,
input[type="text"],
select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  resize: vertical;
  min-height: 6rem;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 111, 234, 0.12);
}

.row {
  display: grid;
  gap: var(--space-2);
}

.row-rate-currency {
  grid-template-columns: 1fr minmax(8rem, 10rem);
  margin-top: var(--space-2);
  align-items: end;
}

@media (max-width: 520px) {
  .row-rate-currency {
    grid-template-columns: 1fr;
  }
}

.btn-primary {
  margin-top: var(--space-2);
  padding: 10px 22px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.form-trust-cue {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: #94a3b8;
}

.btn-secondary {
  margin: 0;
  padding: 10px 20px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-secondary:hover {
  background: var(--copy-hover-bg);
  border-color: #cbd5e1;
}

@keyframes resultsEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results {
  display: block;
  min-height: auto;
  padding-bottom: 0;
  opacity: 0;
  transform: translateY(10px);
  animation: resultsEnter 0.3s ease forwards;
}

.cost-banner {
  margin: 0 0 20px;
  padding: 14px 16px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--navy);
  background: var(--cost-highlight-bg);
  border: 1px solid rgba(91, 194, 54, 0.22);
  border-radius: 8px;
  border-left: 5px solid var(--green);
}

.cost-banner--plain {
  font-weight: 500;
}

.cost-banner__text {
  font-weight: 500;
}

.cost-banner__amount {
  color: var(--green);
  font-weight: 700;
}

.output-container {
  display: block;
  min-height: auto;
  padding-bottom: 8px;
}

.output-container--focused {
  padding-top: 4px;
}

.output-section {
  margin-bottom: 0;
}

.output-section:last-child {
  margin-bottom: 0;
}

.output-block {
  padding-top: 0;
}

.output-title--primary {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--navy);
}

.output-title--muted {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.output-block--followup {
  margin-top: var(--space-3);
}

.output-block-head--followup-title {
  margin-bottom: 10px;
  justify-content: flex-start;
}

.followup-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.followup-grid::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10%;
  bottom: 10%;
  width: 1px;
  margin-left: -0.5px;
  background: #e2e8f0;
  pointer-events: none;
  z-index: 0;
}

.followup-cell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100%;
}

.followup-cell-toolbar {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.followup-cell-body {
  flex: 1;
  margin: 0;
}

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

  .followup-grid::before {
    display: none;
  }
}

.message-box {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--navy-deep);
  white-space: pre-line;
  resize: none;
  box-shadow: none;
  outline: none;
}

.message-box a {
  display: inline-block;
  margin: 6px 0;
}

.message-composed {
  margin: 0;
  white-space: pre-line;
}

.output-block--message.message-primary .message-box {
  min-height: 6rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.message-display {
  margin: 0;
}

.message-approval-link {
  font-size: 0.9375rem;
  line-height: 1.5;
  word-break: break-all;
  color: #1e6fea;
  text-decoration: none;
}

.message-approval-link:hover {
  text-decoration: underline;
}

.output-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 8px;
}

.output-title {
  margin: 0;
  padding-top: 2px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--navy);
}

.output-title.output-title--followup-label {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted);
}

.copy-wrap {
  position: relative;
  flex-shrink: 0;
}

.copy-btn {
  margin: 0;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  line-height: 0;
  transition: background 0.2s ease;
}

.copy-btn:hover {
  background: var(--copy-hover-bg);
}

.copy-icon {
  display: block;
}

.copy-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  padding: 3px 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}

.copy-tooltip--visible {
  opacity: 1;
  visibility: visible;
}

.output-body {
  position: relative;
  display: block;
  min-height: 0;
}

pre.out {
  margin: 0;
  padding: 1rem 1.15rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--navy);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Standalone /approve page */
.approve-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.approve-page {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: center;
}

.approve-card {
  width: 100%;
  padding: 22px 22px 20px;
}

.approve-card-title {
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
  line-height: 1.3;
}

.approve-desc {
  margin: 0 0 24px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

.approve-invalid {
  margin: 0;
  padding: 20px 16px;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--error-text);
}

.approve-details {
  margin: 0 0 20px;
  text-align: left;
}

.approve-detail-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.approve-detail-block:first-child {
  padding-top: 0;
}

.approve-detail-block:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.approve-field-label {
  margin: 0 0 8px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.approve-task-list {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--navy);
}

.approve-task-list li {
  margin-bottom: 6px;
}

.approve-task-list li:last-child {
  margin-bottom: 0;
}

.approve-field-value {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--navy);
}

.approve-field-value--cost {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.approve-context {
  margin: 0 0 20px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--navy);
  text-align: center;
}

.button-group {
  display: flex;
  gap: 12px;
}

.button-group button {
  flex: 1;
  height: 48px;
  border-radius: 8px;
  font-weight: 500;
}

.approve-button-group {
  margin-bottom: 20px;
}

.approve-card .button-group .btn-primary {
  margin-top: 0;
  padding: 0 18px;
  font-weight: 500;
  color: #fff;
  background: #2563eb;
  border-radius: 8px;
}

.approve-card .button-group .btn-primary:hover {
  background: #1d4ed8;
}

.btn-decline-action {
  padding: 0 18px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #fff;
  background: #ef4444;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-decline-action:hover {
  background: #dc2626;
}

.approve-trust {
  margin: 0;
  padding-top: 4px;
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

.approve-result {
  margin: 0;
  padding: 24px 20px;
  text-align: center;
  border-radius: 8px;
}

.approve-result--approved {
  background: var(--cost-highlight-bg);
  border: 1px solid rgba(91, 194, 54, 0.28);
}

.approve-result--declined {
  background: #f8fafc;
  border: 1px solid var(--border);
}

#approve-main {
  opacity: 1;
  transition: opacity 0.2s ease;
}

#approve-main.approve-main--leaving {
  opacity: 0;
}

.approve-result--enter {
  opacity: 0;
  transition: opacity 0.28s ease;
}

.approve-result--enter.approve-result--enter-active {
  opacity: 1;
}

.approve-result-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.approve-result-title {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
}

.approve-result-message {
  margin: 0 0 14px;
  max-width: 100%;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--navy);
}

.confirmation-box {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--navy);
  text-align: left;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.approve-confirm-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  justify-content: center;
}

.approve-copy-wrap {
  margin-top: 2px;
}
