:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --ink: #17202a;
  --muted: #64707d;
  --panel: #fffdf8;
  --line: #d9d2c6;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #a33b2b;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.86);
  backdrop-filter: blur(12px);
}

.brand {
  font-weight: 760;
  text-decoration: none;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
}

.link-button {
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 32px auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.narrow {
  max-width: 760px;
  margin: 0 auto;
}

.section-heading {
  margin-bottom: 24px;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.12;
  margin-bottom: 8px;
}

h2 {
  font-size: 18px;
  margin: 28px 0 12px;
}

.muted,
.section-heading p {
  color: var(--muted);
}

.eyeline {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 8px;
}

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

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

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

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

label {
  display: grid;
  gap: 8px;
}

label span,
.field-label {
  color: #2d3743;
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

input:focus,
button:focus,
.button:focus {
  outline: 3px solid rgba(15, 118, 110, 0.24);
  outline-offset: 2px;
}

button,
.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 16px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

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

.compact {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
}

.alert {
  border: 1px solid rgba(163, 59, 43, 0.3);
  background: rgba(163, 59, 43, 0.08);
  color: var(--danger);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.notice {
  border: 1px solid rgba(15, 118, 110, 0.26);
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent-dark);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 18px 0 4px;
}

.document-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1.5fr 0.7fr 1.2fr;
  gap: 16px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.signer-row {
  grid-template-columns: 1fr 1.45fr 0.7fr 1fr 1.1fr;
}

.row:first-child {
  border-top: 0;
}

.row.head {
  background: #f7f3ea;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.audit-list article {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}

.audit-list span,
.audit-list code {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.signing-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 128px);
}

.signer-panel {
  align-self: start;
}

.pdf-panel {
  padding: 0;
  overflow: hidden;
}

.pdf-panel iframe {
  width: 100%;
  min-height: calc(100vh - 130px);
  border: 0;
  background: white;
}

#signature-pad {
  width: 100%;
  height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  display: block;
}

.toolbar {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-toolbar {
  margin-top: 0;
  align-items: center;
}

.page-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  min-width: 88px;
  text-align: center;
}

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

.position-picker {
  display: grid;
  gap: 12px;
}

.position-picker[hidden] {
  display: none;
}

.position-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.pdf-click-wrap {
  position: relative;
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ece8df;
  padding: 12px;
}

#pdf-position-canvas {
  display: block;
  max-width: 100%;
  background: white;
  box-shadow: 0 10px 28px rgba(23, 32, 42, 0.14);
  cursor: crosshair;
}

.signature-marker {
  position: absolute;
  width: 180px;
  height: 70px;
  transform: translate(12px, 12px);
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.file-button {
  margin: 0;
}

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

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.check input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

@media (max-width: 840px) {
  .topbar {
    padding: 0 18px;
  }

  .two,
  .three,
  .signing-layout {
    grid-template-columns: 1fr;
  }

  .document-header {
    display: grid;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
