:root {
  --bg: #f5efe6;
  --surface: rgba(255, 251, 245, 0.86);
  --surface-strong: #fffdfa;
  --surface-dark: #17211f;
  --text: #1b2521;
  --muted: #5d6661;
  --line: rgba(27, 37, 33, 0.1);
  --accent: #ba5134;
  --accent-deep: #8c3823;
  --accent-soft: rgba(186, 81, 52, 0.12);
  --green: #2c7a63;
  --gold: #b98929;
  --blue: #3c5d9c;
  --danger: #8a4032;
  --shadow: 0 24px 80px rgba(92, 64, 32, 0.12);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(185, 137, 41, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(44, 122, 99, 0.12), transparent 26%),
    linear-gradient(135deg, #f8f3eb 0%, #efe5d8 52%, #fbf7f1 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

input,
select {
  width: 100%;
  padding: 14px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
}

label span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.ambient {
  position: fixed;
  inset: auto;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.5;
  pointer-events: none;
}

.ambient-one {
  top: -120px;
  left: -100px;
  background: rgba(185, 137, 41, 0.2);
}

.ambient-two {
  right: -120px;
  bottom: -100px;
  background: rgba(44, 122, 99, 0.2);
}

.eyebrow,
.section-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.73rem;
  color: var(--muted);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(145deg, #d3784f, #8c5436);
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}

.brand-block h1,
.login-side h2,
.topbar h2,
.panel h3,
.panel h4 {
  margin: 0;
}

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

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px);
  gap: 28px;
  width: min(1180px, 100%);
}

.login-side,
.login-card,
.sidebar,
.topbar,
.panel,
.metric-card,
.callout,
.send-card,
.session-card,
.tool-panel,
.canvas-panel,
.properties-panel,
.customer-card,
.security-panel-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.48);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.login-side,
.login-card,
.topbar,
.panel,
.tool-panel,
.canvas-panel,
.properties-panel,
.customer-card,
.security-panel-card {
  border-radius: var(--radius-xl);
}

.login-side,
.login-card {
  padding: 32px;
}

.login-side {
  display: grid;
  gap: 22px;
}

.login-side h2 {
  font-family: "DM Serif Display", serif;
  font-size: clamp(2rem, 3.6vw, 3.4rem);
  font-weight: 400;
  line-height: 1.02;
}

.login-copy,
.credential-card p,
.note-card p,
.session-card p,
.callout p,
.instruction-card p,
.empty-properties p,
.create-user-copy,
.upload-info {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.credential-card {
  padding: 22px;
  border-radius: var(--radius-lg);
  background: rgba(23, 33, 31, 0.94);
  color: #f7f7f2;
}

.credential-card .eyebrow,
.credential-card p {
  color: rgba(247, 247, 242, 0.76);
}

.credential-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.12rem;
}

.security-notes {
  display: grid;
  gap: 12px;
}

.note-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
}

.note-dot,
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--green);
  margin-top: 8px;
  flex: 0 0 auto;
}

.login-card {
  display: grid;
  gap: 20px;
  align-content: start;
}

.card-top,
.topbar,
.topbar-actions,
.field-list-head,
.canvas-toolbar,
.page-controls,
.properties-actions,
.helper-row,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.card-top {
  align-items: flex-start;
}

.lang-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.lang-btn {
  padding: 10px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.lang-btn.active {
  background: var(--surface-dark);
  color: #fff;
}

#loginForm,
.properties-form {
  display: grid;
  gap: 16px;
}

#createUserForm {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.form-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.create-user-block {
  display: grid;
  gap: 16px;
}

.create-user-head {
  display: grid;
  gap: 6px;
}

.saved-users-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
}

.saved-users-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--accent-deep);
  font-weight: 700;
}

.saved-users-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.saved-user-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.saved-user-item strong,
.saved-user-item span {
  display: block;
}

.saved-user-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.feedback {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
}

.feedback.error {
  background: rgba(138, 64, 50, 0.12);
  color: var(--danger);
}

.feedback.success {
  background: rgba(44, 122, 99, 0.12);
  color: var(--green);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.text-btn,
.tool-button,
.nav-item {
  border-radius: 16px;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.text-btn:hover,
.tool-button:hover,
.nav-item:hover {
  transform: translateY(-1px);
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 14px 18px;
}

.primary-btn {
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  color: #fff;
}

.secondary-btn {
  background: var(--surface-strong);
  color: var(--text);
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.text-btn {
  background: transparent;
  color: var(--accent-deep);
  padding: 0;
}

.wide {
  width: 100%;
}

.compact {
  padding: 10px 14px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 26px 22px;
  background: rgba(23, 33, 31, 0.94);
  color: #eff4ed;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .eyebrow,
.sidebar p {
  color: rgba(239, 244, 237, 0.74);
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 30px;
}

.nav-item {
  padding: 14px 16px;
  background: transparent;
  color: rgba(239, 244, 237, 0.84);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.session-card {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.main-content {
  padding: 28px;
  display: grid;
  gap: 24px;
}

.topbar,
.panel {
  padding: 28px;
}

.topbar h2 {
  max-width: 780px;
  font-family: "DM Serif Display", serif;
  font-size: clamp(1.9rem, 2.4vw, 3rem);
  font-weight: 400;
  line-height: 1.08;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.status-pill.soft {
  background: rgba(255, 255, 255, 0.56);
}

.status-dot {
  margin-top: 0;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

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

.metric-card {
  padding: 22px;
  border-radius: var(--radius-lg);
}

.metric-card p,
.metric-card span {
  margin: 0;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 1.95rem;
}

.metric-card.accent {
  background: linear-gradient(145deg, rgba(186, 81, 52, 0.94), rgba(140, 56, 35, 0.94));
  color: #fff;
}

.metric-card.accent p,
.metric-card.accent span {
  color: rgba(255, 255, 255, 0.82);
}

.callout {
  margin-top: 22px;
  padding: 22px;
  border-radius: var(--radius-lg);
}

.callout strong {
  display: block;
  margin-bottom: 6px;
}

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

.upload-field {
  grid-column: span 2;
}

.helper-row {
  margin: 18px 0 22px;
  align-items: center;
}

.send-card {
  margin-bottom: 22px;
  padding: 22px;
  border-radius: var(--radius-lg);
}

.send-card-head,
.send-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.send-actions {
  margin: 18px 0;
  justify-content: flex-start;
}

.generated-link-field,
.link-info {
  display: block;
}

.generated-link-field input {
  background: rgba(255, 255, 255, 0.9);
}

.link-info {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.tool-panel,
.canvas-panel,
.properties-panel {
  padding: 22px;
}

.tool-panel,
.properties-panel {
  display: grid;
  gap: 18px;
}

.tool-list,
.field-list,
.security-grid,
.customer-grid {
  display: grid;
  gap: 12px;
}

.customer-preview-state,
.customer-preview-shell,
.customer-action-card {
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--line);
}

.customer-preview-state {
  padding: 24px;
}

.customer-preview-state strong {
  display: block;
  margin-bottom: 8px;
}

.tool-button {
  padding: 14px 16px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
  border: 1px solid transparent;
}

.tool-button.active {
  background: rgba(186, 81, 52, 0.14);
  border-color: rgba(186, 81, 52, 0.22);
  color: var(--accent-deep);
}

.instruction-card,
.field-list-card,
.empty-properties {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
}

.field-list {
  margin-top: 14px;
}

.field-list-item {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.field-list-item.active {
  border-color: rgba(186, 81, 52, 0.28);
  box-shadow: inset 0 0 0 1px rgba(186, 81, 52, 0.12);
}

.field-list-item button {
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
}

.field-list-meta {
  font-size: 0.86rem;
  color: var(--muted);
}

.canvas-panel {
  min-height: 760px;
}

.pdf-stage {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 620px;
  overflow: auto;
  padding: 20px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.44)),
    repeating-linear-gradient(
      45deg,
      rgba(27, 37, 33, 0.018) 0,
      rgba(27, 37, 33, 0.018) 12px,
      transparent 12px,
      transparent 24px
    );
  border: 1px solid var(--line);
}

.pdf-placeholder {
  max-width: 380px;
  padding: 28px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px dashed rgba(27, 37, 33, 0.16);
  text-align: center;
}

.pdf-placeholder strong {
  display: block;
  margin-bottom: 8px;
}

.pdf-canvas-element,
.pdf-overlay {
  display: none;
}

.pdf-canvas-element.ready,
.pdf-overlay.ready {
  display: block;
}

.pdf-canvas-element {
  position: relative;
  z-index: 1;
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(27, 37, 33, 0.12);
  background: white;
}

.pdf-overlay {
  position: absolute;
  inset: 20px auto auto 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.overlay-field {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  user-select: none;
  touch-action: none;
  box-shadow: 0 12px 22px rgba(27, 37, 33, 0.16);
}

.overlay-field.selected {
  outline: 2px solid rgba(23, 33, 31, 0.7);
  outline-offset: 2px;
}

.overlay-field.type-signature {
  background: linear-gradient(145deg, rgba(186, 81, 52, 0.96), rgba(140, 56, 35, 0.96));
}

.overlay-field.type-fullName,
.overlay-field.type-text {
  background: rgba(44, 122, 99, 0.92);
}

.overlay-field.type-date {
  background: rgba(60, 93, 156, 0.9);
}

.overlay-field.type-checkbox {
  background: rgba(185, 137, 41, 0.92);
}

.overlay-field.type-initial {
  background: rgba(100, 70, 140, 0.9);
}

.properties-form .hidden {
  display: none;
}

.customer-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.customer-preview-shell {
  padding: 22px;
}

.customer-preview-head,
.customer-preview-controls,
.customer-preview-layout {
  display: flex;
  gap: 16px;
}

.customer-preview-head {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.customer-preview-controls {
  align-items: center;
  flex-wrap: wrap;
}

.customer-preview-meta,
.customer-preview-state p,
.customer-action-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.customer-preview-layout {
  align-items: flex-start;
}

.customer-document-panel {
  flex: 1 1 auto;
}

.customer-action-panel {
  width: 360px;
  display: grid;
  gap: 16px;
}

.customer-action-card {
  padding: 20px;
}

.customer-pdf-stage {
  min-height: 720px;
}

.customer-overlay {
  pointer-events: auto;
}

.customer-field {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 1px solid rgba(27, 37, 33, 0.14);
  background: rgba(255, 255, 255, 0.92);
  overflow: hidden;
}

.customer-field.active {
  box-shadow: 0 0 0 3px rgba(186, 81, 52, 0.18);
  border-color: rgba(186, 81, 52, 0.48);
}

.customer-field input,
.customer-field label,
.customer-sign-trigger {
  width: 100%;
  height: 100%;
}

.customer-field input[type="text"] {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 10px 12px;
}

.customer-checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.88rem;
  color: var(--text);
}

.customer-checkbox-field input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.customer-sign-trigger {
  border: 0;
  background: linear-gradient(145deg, rgba(186, 81, 52, 0.12), rgba(140, 56, 35, 0.14));
  color: var(--accent-deep);
  font-weight: 700;
  padding: 0 10px;
}

.customer-sign-trigger.signed {
  background: rgba(255, 255, 255, 0.96);
}

.customer-sign-trigger img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.signature-draw-canvas {
  width: 100%;
  min-height: 150px;
  border-radius: 18px;
  border: 1px dashed rgba(27, 37, 33, 0.18);
  background: white;
  margin: 14px 0 16px;
  touch-action: none;
}

.customer-consent-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 18px;
  color: var(--text);
  line-height: 1.6;
}

.customer-consent-line input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

.customer-card,
.security-panel-card {
  padding: 22px;
}

.customer-card h4,
.security-panel-card h4 {
  margin: 8px 0 10px;
}

.customer-card p:not(.eyebrow),
.security-panel-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.security-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.public-preview .ambient,
body.public-preview .sidebar,
body.public-preview .topbar,
body.public-preview [data-section="dashboard"],
body.public-preview [data-section="editor"],
body.public-preview [data-section="security"] {
  display: none !important;
}

body.public-preview .app-shell {
  display: block;
}

body.public-preview .main-content {
  padding: 22px;
}

body.public-preview .panel[data-section="customer"] {
  display: block;
}

body.public-preview .customer-grid,
body.public-preview .panel-heading {
  display: none;
}

@media (max-width: 1280px) {
  .metric-grid,
  .document-form,
  .customer-grid,
  .security-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .customer-preview-layout {
    flex-direction: column;
  }

  .customer-action-panel {
    width: 100%;
  }
}

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

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

@media (max-width: 780px) {
  .login-screen,
  .main-content,
  .topbar,
  .panel,
  .sidebar,
  .login-side,
  .login-card {
    padding: 18px;
  }

  .metric-grid,
  .document-form,
  .customer-grid,
  .security-grid {
    grid-template-columns: 1fr;
  }

  .upload-field {
    grid-column: span 1;
  }

  .topbar,
  .panel-heading,
  .helper-row,
  .canvas-toolbar,
  .send-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .pdf-stage {
    min-height: 440px;
    padding: 12px;
  }

  .pdf-overlay {
    inset: 12px auto auto 50%;
  }
}
