:root {
  --font-body: 'Inter', Arial, sans-serif;
  --font-title: 'Sora', Arial, sans-serif;
  --bg: #fbf7f2;
  --panel: #ffffff;
  --ink: #241f1e;
  --muted: #746a65;
  --line: #eaded3;
  --soft: #f5eee7;
  --soft-2: #faf7f2;
  --gold: #c9a26a;
  --gold-dark: #9c7748;
  --dark: #1b1716;
  --danger: #b42318;
  --ok: #16794c;
  --shadow: 0 18px 50px rgba(55, 35, 25, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(201, 162, 106, 0.18), transparent 35%),
    linear-gradient(135deg, #fffaf5 0%, #f7eee6 100%);
}

button,
input,
select,
textarea {
  font-family: var(--font-body);
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
}

h1,
.panel-head h2,
.contract-preview h3 {
  font-family: var(--font-title);
  font-weight: 600;
}

.hero {
  max-width: 1320px;
  margin: 0 auto;
  padding: 34px 22px 22px;
}

.hero-inner {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  min-height: 170px;
  padding: 26px 34px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}

.hero-inner.single {
  grid-template-columns: 260px minmax(0, 1fr);
}

.brand-logo {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
  object-fit: contain;
  justify-self: center;
}

.hero-copy h1 {
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.hero-copy p:not(.eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 760px;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-dark);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 600;
}

.layout {
  max-width: 1320px;
  margin: 0 auto 48px;
  padding: 0 22px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, 0.9fr);
  gap: 22px;
  align-items: start;
}

.signature-layout {
  max-width: 1040px;
  margin: 0 auto 48px;
  padding: 0 22px;
  display: grid;
  gap: 22px;
}

.side-column {
  display: grid;
  gap: 22px;
  position: sticky;
  top: 18px;
}

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

.form-panel,
.preview-panel,
.list-panel,
.sign-panel {
  padding: 24px;
}

.preview-panel {
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.public-preview {
  max-height: none;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head.compact h2 {
  font-size: 26px;
}

.form-panel .panel-head h2 {
  font-size: 30px;
}

.badge {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.muted {
  background: var(--soft);
  color: var(--muted);
}

.badge.ok {
  background: #e9f7ef;
  color: var(--ok);
}

.badge.danger {
  background: #fff0ee;
  color: var(--danger);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 20px;
  margin: 18px 0 16px;
  border-top: 1px solid var(--line);
}

.section-title:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.section-title span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--dark);
  font-weight: 600;
  flex: 0 0 auto;
}

.section-title h3 {
  font-size: 18px;
  font-weight: 600;
}

.section-title.with-action {
  justify-content: space-between;
}

.section-title.with-action > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 400;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(201, 162, 106, 0.16);
}

.full {
  margin-top: 14px;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.repeat-list {
  display: grid;
  gap: 12px;
}

.repeat-item {
  background: var(--soft-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

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

.repeat-head strong {
  font-size: 14px;
  font-weight: 600;
}

.repeat-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.8fr) minmax(0, 0.8fr) 42px;
  gap: 12px;
  align-items: end;
}

.repeat-grid.payment {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.9fr) minmax(0, 0.9fr) 42px;
}

.btn,
.icon-btn,
.link-btn {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn {
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--dark);
  color: #fff;
  box-shadow: 0 12px 28px rgba(27, 23, 22, 0.2);
}

.btn.secondary {
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

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

.btn.danger,
.btn.ghost.danger {
  color: var(--danger);
}

.btn.small {
  padding: 9px 13px;
  font-size: 12px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #fff0ee;
  color: var(--danger);
  font-size: 24px;
  line-height: 1;
}

.link-btn {
  background: transparent;
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.sticky-actions {
  position: sticky;
  bottom: 14px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 16px 34px rgba(55, 35, 25, 0.12);
}

.link-box {
  margin-top: 20px;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 18px;
  padding: 16px;
}

.link-box small {
  color: var(--muted);
  display: block;
  margin-top: 10px;
  line-height: 1.5;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--soft-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}

.summary-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 5px;
}

.summary-card strong {
  font-size: 15px;
  font-weight: 600;
}

.contract-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  line-height: 1.7;
  color: #2d2927;
}

.contract-preview .preview-logo {
  display: block;
  max-width: 180px;
  margin: 0 auto 14px;
}

.contract-preview h3 {
  font-size: 20px;
  margin: 18px 0 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f3f0ec;
  color: #1e1a18;
}

.contract-preview h3:first-child {
  margin-top: 0;
}

.contract-preview p,
.contract-preview ul,
.contract-preview li {
  font-size: 13.5px;
}

.contract-preview p {
  margin: 8px 0;
}

.contract-preview ul {
  margin: 8px 0 8px 18px;
  padding: 0;
}

.contract-preview .signature-preview {
  margin-top: 12px;
  max-width: 240px;
  max-height: 90px;
  border-bottom: 1px solid #bbb;
}

.contracts-list {
  display: grid;
  gap: 10px;
}

.contract-item {
  border: 1px solid var(--line);
  background: var(--soft-2);
  border-radius: 16px;
  padding: 13px;
  display: grid;
  gap: 10px;
}

.contract-item strong {
  font-size: 14px;
  font-weight: 600;
}

.contract-item small {
  color: var(--muted);
  line-height: 1.4;
}

.contract-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkline {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  margin-top: 18px;
}

.checkline input {
  width: auto;
  margin-top: 3px;
}

.signature-box {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.signature-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--soft-2);
}

.signature-head strong {
  font-weight: 600;
}

canvas {
  display: block;
  width: 100%;
  height: 190px;
  touch-action: none;
  background: #fff;
}

.public-check {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--soft-2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1e1a18;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  z-index: 20;
}

.hidden {
  display: none !important;
}

@media (max-width: 1080px) {
  .admin-layout,
  .hero-inner,
  .hero-inner.single {
    grid-template-columns: 1fr;
  }

  .side-column {
    position: static;
  }

  .preview-panel {
    max-height: none;
  }

  .brand-logo {
    max-width: 220px;
  }
}

@media (max-width: 760px) {
  .hero,
  .layout,
  .signature-layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero-inner,
  .form-panel,
  .preview-panel,
  .list-panel,
  .sign-panel {
    padding: 18px;
  }

  .grid.two,
  .grid.three,
  .repeat-grid,
  .repeat-grid.payment,
  .link-row,
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }

  .sticky-actions {
    position: static;
  }

  .btn {
    width: 100%;
  }

  .contract-actions .btn {
    width: auto;
  }
}

#signaturePad {
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: contain;
}

.admin-quick-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-user {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--soft-2);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.login-layout {
  width: min(100%, 480px);
}

.login-card {
  padding: 34px;
  text-align: left;
}

.login-logo {
  display: block;
  max-width: 230px;
  width: 76%;
  height: auto;
  margin: 0 auto 24px;
}

.login-card h1 {
  font-family: var(--font-title);
  font-size: clamp(30px, 8vw, 44px);
  line-height: 1;
  letter-spacing: -0.03em;
}

.login-intro {
  color: var(--muted);
  line-height: 1.6;
  margin: 14px 0 22px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.full-button {
  width: 100%;
  justify-content: center;
}

.center {
  text-align: center;
}

@media (max-width: 580px) {
  .login-card {
    padding: 24px;
  }

  .admin-quick-actions {
    align-items: stretch;
  }
}
