:root {
  --sage: #78948c;
  --sage-dark: #587168;
  --charcoal: #262932;
  --stone: #f2f3f1;
  --white: #ffffff;
  --grey: #e1e6e3;
  --ink: #30343b;
  --muted: #74807c;
  --danger: #9a5f5b;
  --focus: #385d55;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--stone);
  font: 400 14px/1.5 Montserrat, Arial, sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 88px;
  background: var(--white);
  border-bottom: 1px solid var(--grey);
  display: flex;
  align-items: center;
  gap: 34px;
  padding: 18px clamp(20px, 5vw, 78px);
}

.logo { width: 180px; height: auto; display: block; }

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
}

.nav button {
  border: 0;
  background: transparent;
  color: #68716f;
  padding: 10px 12px;
  border-radius: 5px;
  font-size: 12px;
}

.nav button:hover,
.nav button.active {
  color: var(--charcoal);
  background: var(--stone);
}

.help {
  font: 500 17px "Cormorant Garamond", serif;
  color: var(--sage);
}

.page {
  max-width: 1170px;
  margin: auto;
  padding: 58px 30px 80px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--white);
  border: 1px solid var(--grey);
  padding: 42px;
  border-radius: 4px;
  box-shadow: 0 18px 45px #26293212;
  text-align: center;
}

.login-logo { width: 190px; margin: 0 auto 34px; }
.login-box h1, .section-head h1, .detail-hero h1 { font-weight: 300; margin: 0; }
.login-box h1 { font-size: 27px; margin-bottom: 9px; }
.login-box p, .muted { color: var(--muted); }

.complete-box {
  padding-top: 48px;
  padding-bottom: 48px;
}

.success-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #e6f0eb;
  color: var(--sage-dark);
  font-size: 31px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  gap: 13px;
  margin-top: 24px;
  text-align: left;
}

label {
  display: grid;
  gap: 6px;
  font-size: 11px;
  color: #64716c;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--grey);
  border-radius: 4px;
  padding: 12px;
  color: var(--ink);
  background: var(--white);
}

textarea { min-height: 96px; resize: vertical; }

input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.primary, .secondary, .danger-link, .profile {
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
}

.primary {
  border: 0;
  padding: 13px 18px;
  background: var(--sage);
  color: var(--white);
  box-shadow: 0 6px 16px #78948c38;
}

.primary:hover { background: #638078; }

.secondary {
  border: 1px solid #c8d4cf;
  background: var(--white);
  padding: 12px 16px;
  color: var(--sage-dark);
}

.danger-link {
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 10px 0;
  text-decoration: underline;
}

.status-note {
  min-height: 20px;
  margin-top: 16px;
  color: var(--sage);
  font: 500 15px "Cormorant Garamond", serif;
}

.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--sage);
  font-weight: 500;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 64px;
  align-items: center;
  min-height: 430px;
}

.hero h1 {
  margin: 7px 0 18px;
  font-size: 45px;
  line-height: 1.07;
  font-weight: 300;
}

.hero h1 em {
  font: 500 48px/1 "Cormorant Garamond", serif;
  color: var(--sage);
}

.hero p { max-width: 520px; margin: 0 0 25px; color: var(--muted); }

.hero-card {
  position: relative;
  min-height: 335px;
  border-radius: 10px;
  background: linear-gradient(135deg, #8aa39a, var(--sage));
  padding: 28px;
  box-shadow: 0 20px 40px #78948c32;
  overflow: hidden;
}

.mini-word {
  position: absolute;
  right: 28px;
  top: 31px;
  color: var(--white);
  font: 500 37px/1 "Cormorant Garamond", serif;
}

.mini-doc {
  position: absolute;
  z-index: 1;
  bottom: 26px;
  left: 26px;
  width: 250px;
  border-radius: 8px;
  background: var(--white);
  padding: 20px;
  box-shadow: 0 16px 25px #30443924;
}

.mini-lock {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--charcoal);
  color: #bdd4ca;
  font: 20px "Cormorant Garamond", serif;
}

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

.section-head h1 { font-size: 31px; margin-top: 5px; }

.empty, .panel, .detail-card, .settings-card {
  background: var(--white);
  border: 1px solid var(--grey);
  border-radius: 8px;
}

.empty {
  min-height: 390px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 35px;
}

.empty h2 { margin: 0 0 8px; font-size: 21px; font-weight: 300; }
.empty p { max-width: 390px; margin: 0 auto 19px; color: var(--muted); }

.agreement-list { display: grid; gap: 10px; width: 100%; }

.agreement-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--white);
  border: 1px solid #c4d3ce;
  border-left: 4px solid var(--sage);
  border-radius: 8px;
  padding: 17px 18px;
  color: var(--ink);
}

.file-badge {
  width: 34px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #e6eeea;
  color: var(--sage);
  font-size: 10px;
  font-weight: 600;
}

.agreement-copy { flex: 1; }
.agreement-copy b, .profile-summary b { display: block; font-size: 12px; font-weight: 600; }
.agreement-copy small, .profile-summary span { display: block; color: var(--muted); font-size: 11px; }

.status-pill {
  border-radius: 20px;
  background: #eef3f0;
  color: #638078;
  padding: 4px 8px;
  font-size: 10px;
}

.dashboard {
  display: grid;
  gap: 18px;
}

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

.metric-grid article {
  background: var(--white);
  border: 1px solid var(--grey);
  border-radius: 8px;
  padding: 18px;
}

.metric-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid b {
  color: var(--ink);
  font-size: 30px;
  font-weight: 400;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 16px;
}

.dashboard-panel {
  padding: 20px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 400;
}

.agreement-list.compact { gap: 8px; }
.agreement-list.compact .agreement-row { padding: 12px 14px; }

.template-shell {
  display: block;
  min-height: 300px;
  text-align: left;
}

.template-list {
  display: grid;
  gap: 10px;
  width: 100%;
}

.template-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px;
  border: 1px solid #c4d3ce;
  border-left: 4px solid var(--sage);
  border-radius: 8px;
  background: var(--white);
}

.template-card b,
.template-card small {
  display: block;
}

.template-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid #bdcec7;
  padding-bottom: 24px;
  margin-bottom: 25px;
}

.detail-hero h1 { font-size: 32px; margin-top: 6px; }
.detail-hero p { margin: 0; color: var(--muted); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-card { padding: 24px; }
.detail-card.sage-edge { border-top: 4px solid var(--sage); }
.detail-card h2 { font-size: 19px; font-weight: 400; margin: 12px 0 7px; }
.detail-card p { color: var(--muted); min-height: 52px; }
.stack-action { display: block; margin-top: 10px; width: max-content; }

.recipient-list { display: grid; gap: 8px; margin-top: 14px; }
.recipient-row { border-top: 1px solid var(--grey); padding-top: 10px; }

.profile {
  min-width: 38px;
  min-height: 38px;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--charcoal);
  color: #d8e4df;
}

.profile-wrap { position: relative; }

.profile-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 46px;
  width: 230px;
  padding: 9px;
  background: var(--white);
  border: 1px solid var(--grey);
  border-radius: 7px;
  box-shadow: 0 14px 34px #2629321f;
  z-index: 5;
}

.profile-menu.open { display: block; }
.profile-summary { padding: 8px 10px 11px; border-bottom: 1px solid var(--grey); }
.profile-menu button { width: 100%; border: 0; background: transparent; padding: 10px; text-align: left; font-size: 12px; border-radius: 4px; }
.profile-menu button:hover { background: var(--stone); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #2629328a;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: min(460px, 100%);
  background: var(--white);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 80px #1113197d;
}

.modal-card:has(.signature-modal) {
  width: min(760px, 100%);
}

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

.modal-head h2 { margin: 0 0 7px; font-size: 21px; font-weight: 300; }
.close { border: 0; background: transparent; color: var(--muted); font-size: 19px; }

.prepare-shell,
.sign-shell {
  max-width: 1280px;
  margin: 0 auto;
}

.prepare-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tool-panel {
  position: sticky;
  top: 18px;
  background: var(--white);
  border: 1px solid var(--grey);
  border-radius: 8px;
  padding: 16px;
}

.tool-panel h2 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 500;
}

.tool-button {
  display: block;
  width: 100%;
  border: 1px solid #c8d4cf;
  background: var(--white);
  color: var(--ink);
  text-align: left;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 8px;
  font-size: 12px;
}

.tool-button.active,
.tool-button:hover {
  border-color: var(--sage);
  background: #eef4f1;
  color: var(--sage-dark);
}

.pdf-workspace {
  display: grid;
  gap: 18px;
  justify-items: center;
  overflow: auto;
  padding: 18px;
  background: #dfe4e1;
  border: 1px solid #c8d4cf;
  border-radius: 8px;
  min-height: 480px;
}

.pdf-workspace.signer {
  max-height: none;
  margin-bottom: 110px;
}

.pdf-page {
  position: relative;
  background: var(--white);
  box-shadow: 0 16px 35px #1d262233;
}

.pdf-page canvas {
  display: block;
  max-width: none;
}

.pdf-overlay {
  position: absolute;
  inset: 0;
}

.field-box {
  position: absolute;
  border: 2px solid #557a71;
  background: #e6f0ebd9;
  color: #28443d;
  display: grid;
  place-items: center;
  padding: 2px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.field-box.selected {
  border-color: #263d38;
  box-shadow: 0 0 0 2px #78948c4d;
}

.field-box.signature {
  border-color: #43516a;
  background: #e5e8efdd;
}

.field-box.date {
  border-color: #7b6d45;
  background: #f4eedadd;
}

.field-box.checkbox {
  border-color: #6d9188;
  background: #ffffff99;
  min-width: 14px;
  min-height: 14px;
}

.field-box.radio {
  border-color: #6d9188;
  background: #ffffff99;
  border-radius: 50%;
  min-width: 14px;
  min-height: 14px;
}

.field-box span:first-child {
  pointer-events: none;
}

.field-remove {
  position: absolute;
  right: -8px;
  top: -9px;
  width: 17px;
  height: 17px;
  border: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--danger);
  color: var(--white);
  font-size: 10px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--white);
  border-radius: 3px;
  background: var(--sage-dark);
  cursor: nwse-resize;
  box-shadow: 0 1px 4px #00000035;
  touch-action: none;
}

.field-options {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--grey);
}

.option-empty {
  font-size: 12px;
}

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

.option-card label {
  font-size: 11px;
}

.option-card input[type="text"],
.option-card input:not([type]) {
  padding: 9px;
  font-size: 12px;
}

.option-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.option-check input {
  width: 15px;
  height: 15px;
}

.sign-head {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 980px;
  margin: 28px auto 22px;
  padding: 0 18px;
}

.sign-intro-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(135deg, #2f423d, #dfe4e1);
}

.sign-intro-card {
  width: min(760px, 100%);
  background: #fffffff7;
  border-radius: 8px;
  padding: 34px;
  box-shadow: 0 30px 90px #11131955;
}

.sign-intro-card h1 {
  margin: 10px 0;
  font-size: 32px;
  font-weight: 300;
}

.sign-intro-card p {
  color: var(--muted);
  max-width: 620px;
}

.intro-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0;
}

.intro-meta span {
  border: 1px solid #c8d4cf;
  border-radius: 999px;
  padding: 7px 11px;
  color: #4f625d;
  font-size: 12px;
  background: #f7faf8;
}

.sign-logo {
  width: 155px;
  height: auto;
}

.sign-head h1 {
  margin: 4px 0 6px;
  font-size: 31px;
  font-weight: 300;
}

.sign-head p {
  margin: 0;
  color: var(--muted);
}

.sign-field {
  position: absolute;
  display: block;
  background: #ffffff66;
  border: 1px solid #6d9188;
  border-radius: 2px;
  padding: 1px;
  font-size: 11px;
  box-shadow: inset 0 0 0 1px #ffffff66;
}

.sign-field input[type="text"],
.sign-field input[type="date"] {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  padding: 2px 5px;
  background: transparent;
  color: #172723;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

.sign-field.signature {
  background: #ffffffd9;
}

.signature-adopt {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  color: #31564e;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.signature-adopt.signed {
  color: transparent;
}

.signature-clear {
  position: absolute;
  right: 2px;
  top: 2px;
  border: 0;
  border-radius: 3px;
  background: #ffffffd9;
  color: #5c706b;
  padding: 2px 5px;
  font-size: 9px;
}

.signature-modal {
  display: grid;
  gap: 16px;
}

.signature-modal label {
  display: grid;
  gap: 6px;
  color: #4f625d;
  font-size: 12px;
  font-weight: 600;
}

.signature-modal input {
  border: 1px solid #c8d4cf;
  border-radius: 4px;
  padding: 10px;
  color: var(--ink);
}

.signature-pad-wrap {
  height: 250px;
  border: 2px solid #6d9188;
  border-radius: 8px;
  background:
    linear-gradient(transparent 74%, #c8d4cf 75%, transparent 76%),
    #fff;
  overflow: hidden;
}

.signature-pad-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.signature-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.sign-field input::placeholder {
  color: #31564e;
  opacity: .72;
  font-weight: 500;
}

.sign-field:focus-within {
  background: #ffffffdb;
  border-color: #3f6960;
  box-shadow: 0 0 0 2px #78948c33;
}

.sign-field.checkbox,
.sign-field.radio {
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.sign-field.checkbox input,
.sign-field.radio input {
  appearance: none;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 1.5px solid #6d9188;
  background: #ffffffcc;
}

.sign-field.checkbox input {
  border-radius: 2px;
}

.sign-field.radio input {
  border-radius: 50%;
}

.sign-field.checkbox input:checked {
  background: #6d9188;
  box-shadow: inset 0 0 0 3px #ffffff;
}

.sign-field.radio input:checked {
  background: radial-gradient(circle, #6d9188 0 42%, #ffffffcc 45%);
}

.sign-actions {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: #fffffff2;
  border: 1px solid var(--grey);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 12px 35px #1d26222b;
  z-index: 10;
}

.sign-actions span {
  color: #4f625d;
  font-size: 12px;
  font-weight: 500;
}

.sign-actions .primary {
  min-width: 120px;
}

.sign-actions .status-note {
  grid-column: 1 / -1;
  margin: 0;
}

.complete-timeline {
  display: grid;
  gap: 12px;
  margin: 22px 0;
  text-align: left;
}

.complete-timeline div {
  border-left: 3px solid var(--sage);
  padding-left: 12px;
}

.complete-timeline b {
  display: block;
  color: var(--ink);
}

.complete-timeline span {
  color: var(--muted);
  font-size: 13px;
}

.download-completed {
  display: inline-block;
  text-decoration: none;
}

@media (max-width: 800px) {
  .topbar { gap: 16px; flex-wrap: wrap; }
  .logo { width: 132px; }
  .nav { order: 3; width: 100%; overflow: auto; }
  .help { display: none; }
  .page { padding: 40px 20px; }
  .hero, .detail-grid, .metric-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .hero { gap: 30px; }
  .hero h1 { font-size: 37px; }
  .hero h1 em { font-size: 40px; }
  .section-head, .detail-hero { display: block; }
  .section-head .primary { margin-top: 16px; }
  .prepare-layout { grid-template-columns: 1fr; }
  .tool-panel { position: static; }
  .sign-head { display: block; text-align: center; }
  .sign-actions { grid-template-columns: 1fr; }
}
