@font-face {
  font-family: Inter;
  src: url("/static/fonts/inter.ttf");
}
@font-face {
  font-family: Montserrat;
  src: url("/static/fonts/montserrat.ttf");
  font-weight: 700 900;
}
:root {
  --red: #d40000;
  --orange: #e25200;
  --ink: #161614;
  --paper: #fbf8f3;
  --line: #e4dcd0;
  --muted: #625d55;
  --green: #226149;
  --display: Montserrat, Arial, sans-serif;
  --body: Inter, Arial, sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--body);
}
h1,
h2,
h3,
h4 {
  font-family: var(--display);
  line-height: 1.15;
  letter-spacing: -0.035em;
  margin: 0 0 16px;
}
h1 {
  font-size: clamp(32px, 4vw, 54px);
}
h2 {
  font-size: 28px;
}
h3 {
  font-size: 20px;
}
p {
  margin: 0 0 18px;
}
a {
  color: inherit;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
.button {
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 11px 19px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.4;
  min-height: 44px;
}
button:hover,
.button:hover {
  filter: brightness(0.88);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.primary {
  background: var(--red);
  border-color: var(--red);
}
.quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.danger {
  color: #a00000;
  border-color: #e6aaaa;
  background: #fff;
}
.small {
  padding: 8px 12px;
  font-size: 13px;
}
input,
select,
textarea {
  width: 100%;
  padding: 12px;
  background: #fff;
  border: 1px solid #c5bdb2;
  border-radius: 6px;
  color: var(--ink);
  min-height: 46px;
}
input[type="checkbox"] {
  width: 19px;
  height: 19px;
  min-height: 0;
  accent-color: var(--red);
  flex-shrink: 0;
}
input[type="file"] {
  font-size: 14px;
}
label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 15px;
}
label > input,
label > select {
  margin-top: 6px;
}
input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #e2520066;
  outline-offset: 3px;
}
.muted {
  color: var(--muted);
}
.eyebrow {
  color: var(--red);
  font: 700 12px/1.5 var(--display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.topbar {
  padding: 22px clamp(18px, 4vw, 56px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  font: 800 20px/1 var(--display);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.brand b {
  color: var(--red);
  font-weight: 700;
}
.brand small {
  display: block;
  margin-top: 8px;
  font: 600 9px/1 var(--body);
  letter-spacing: 0.14em;
  color: var(--muted);
}
.top-right {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
}
.dev-banner {
  text-align: center;
  padding: 6px 12px;
  font-size: 12px;
  background: #fff0c4;
  color: #5e4300;
}
main {
  max-width: 1440px;
  margin: auto;
  min-height: calc(100vh - 190px);
  padding: 44px clamp(18px, 4vw, 56px) 72px;
}
footer {
  border-top: 1px solid var(--line);
  padding: 22px clamp(18px, 4vw, 56px);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}
.hidden {
  display: none !important;
}
[hidden] {
  display: none !important;
}
.loading {
  padding: 80px;
  text-align: center;
}
.error-page {
  padding: 80px;
}
.login-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 100px;
  align-items: center;
  max-width: 1100px;
  margin: 36px auto;
}
.hero-title {
  font-size: clamp(44px, 6vw, 76px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.065em;
}
.hero-title em {
  font-style: normal;
  color: var(--red);
}
.hero-copy {
  font-size: 18px;
  max-width: 470px;
  color: var(--muted);
}
.hero-rule {
  height: 7px;
  width: 135px;
  margin: 35px 0;
  background: linear-gradient(
    90deg,
    #e25200 0 25%,
    #c35000 25% 50%,
    #a41e00 50% 75%,
    #7a1d00 75%
  );
}
.trust-row {
  display: flex;
  gap: 25px;
  font-size: 13px;
  color: var(--muted);
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
}
.login-card {
  padding: 36px;
  box-shadow: 0 12px 50px #16161408;
  border-top: 4px solid var(--red);
}
.login-card button[type="submit"] {
  width: 100%;
  margin-top: 8px;
}
.caption {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.page-head {
  margin: 0 0 32px;
}
.page-head h1 {
  margin-bottom: 10px;
}
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 24px 0 32px;
  overflow: auto;
}
.tabs button {
  white-space: nowrap;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 16px 22px;
  border-bottom: 3px solid transparent;
}
.tabs button.active {
  color: var(--red);
  border-bottom-color: var(--red);
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 30px;
}
.stat {
  padding: 24px;
  border-left: 3px solid var(--line);
  background: #fff;
}
.stat strong {
  display: block;
  font: 700 34px var(--display);
  letter-spacing: -0.04em;
  margin-bottom: 4px;
}
.stat span {
  font-size: 13px;
  color: var(--muted);
}
.stat:first-child {
  border-left-color: var(--red);
}
.row {
  display: flex;
  gap: 16px;
  align-items: center;
}
.stack {
  display: grid;
  gap: 14px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.document-list {
  display: grid;
  gap: 12px;
}
.document-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
}
.doc-icon {
  width: 48px;
  height: 57px;
  border: 1px solid #e7c7be;
  border-radius: 4px;
  background: #fff5ee;
  display: grid;
  place-items: center;
  color: var(--red);
  font-size: 12px;
  font-weight: bold;
}
.document-row h3 {
  margin-bottom: 7px;
}
.document-meta {
  font-size: 13px;
  color: var(--muted);
}
.badge {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  background: #f3ede4;
  color: #625d55;
  white-space: nowrap;
}
.badge.pending {
  color: #955000;
  background: #fff0d0;
}
.badge.signed,
.badge.delivered {
  color: #226149;
  background: #e3f1e9;
}
.badge.published {
  color: #3c5174;
  background: #e8edf6;
}
.badge.failed,
.badge.revoked {
  color: #a00000;
  background: #fde8e4;
}
.badge.draft {
  background: #f6e9e4;
  color: #a44119;
}
.empty {
  padding: 60px 30px;
  text-align: center;
  border: 1px dashed #c9beb0;
  border-radius: 12px;
}
.empty h2 {
  font-size: 25px;
}
.empty p {
  max-width: 480px;
  margin: 0 auto 24px;
}
.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 28px;
  align-items: start;
}
.preview-surface {
  background: #ede8e0;
  padding: 24px;
  border-radius: 10px;
  border: 1px solid #ded6ca;
  overflow: hidden;
}
.pdf-page {
  position: relative;
  background: white;
  margin: 0 auto 24px;
  box-shadow: 0 3px 15px #00000012;
  max-width: 820px;
  line-height: 0;
}
.pdf-page img {
  width: 100%;
  height: auto;
  display: block;
}
.page-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 9px;
}
.field-overlay {
  position: absolute;
  border: 1.5px dashed var(--red);
  background: #d400000d;
  display: flex;
  align-items: center;
  padding: 2px 5px;
  color: #a10000;
  font: 12px/1.1 var(--body);
  overflow: hidden;
  min-height: 0;
  border-radius: 2px;
  cursor: default;
  justify-content: flex-start;
}
.field-overlay.editable {
  cursor: move;
  touch-action: none;
}
.field-overlay.selected {
  background: #d4000023;
  border-style: solid;
  box-shadow: 0 0 0 2px #d4000033;
}
.field-overlay.signature {
  font-family: Georgia, serif;
  font-style: italic;
}
.editor-side {
  position: sticky;
  top: 20px;
}
.editor-side .card {
  padding: 22px;
}
.field-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 14px 0;
}
.field-card.selected {
  border-color: var(--red);
}
.field-card label {
  font-size: 12px;
  margin: 8px 0;
}
.field-card input,
.field-card select {
  padding: 7px;
  min-height: 35px;
  font-size: 13px;
}
.coord-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.field-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.field-tools button {
  font-size: 12px;
  padding: 8px 10px;
}
.back-link {
  font-size: 14px;
  margin-bottom: 20px;
  display: inline-block;
}
.audit {
  list-style: none;
  margin: 0;
  padding: 0;
}
.audit li {
  border-left: 2px solid var(--line);
  padding: 4px 0 18px 18px;
  font-size: 13px;
}
.audit strong {
  display: block;
  font-size: 14px;
}
.check-label {
  display: flex;
  gap: 12px;
  font-weight: 400;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.6;
}
.check-label input {
  margin-top: 5px;
}
.success-panel {
  padding: 40px;
  background: #e8f1ea;
  border: 1px solid #b7cfbe;
  border-radius: 12px;
  margin-bottom: 28px;
}
.success-panel h2 {
  color: var(--green);
}
.status-banner {
  padding: 14px 20px;
  background: #f3ede4;
  margin-bottom: 20px;
  border-radius: 6px;
  font-size: 14px;
}
.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 16px;
  background: #faf8f4;
}
td {
  padding: 16px;
  border-top: 1px solid var(--line);
}
#notice {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 16px 24px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 5px 25px #0002;
  z-index: 100;
  max-width: 90vw;
  width: max-content;
  font-size: 14px;
}
#notice.error {
  background: #a60000;
}
dialog {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 550px;
  width: calc(100% - 36px);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 15px 80px #0003;
}
dialog::backdrop {
  background: #16161488;
}
.close-modal {
  margin-top: 20px;
}
.link-copy {
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
  background: #f6f3ee;
  padding: 15px;
}
.revision-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.fineprint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 16px;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.step-line {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
}
.step-line b {
  color: var(--red);
}
.hash {
  font: 11px/1.7 monospace;
  word-break: break-all;
  color: var(--muted);
}
@media (max-width: 1000px) {
  .login-grid {
    gap: 40px;
  }
  .editor-layout {
    grid-template-columns: minmax(0, 1fr) 290px;
  }
  .document-row {
    grid-template-columns: 44px 1fr;
  }
  .document-row > .actions {
    grid-column: 2;
  }
  .brand {
    font-size: 17px;
  }
  .top-right > span {
    display: none;
  }
}
@media (max-width: 720px) {
  main {
    padding-top: 28px;
  }
  .login-grid {
    grid-template-columns: 1fr;
    margin: 0;
    gap: 28px;
  }
  .hero-title {
    font-size: 46px;
  }
  .hero-copy {
    font-size: 16px;
  }
  .hero-rule {
    margin: 22px 0;
  }
  .trust-row {
    display: none;
  }
  .login-card {
    padding: 24px;
  }
  .topbar {
    padding: 18px;
  }
  .brand img {
    width: 28px;
    height: 28px;
  }
  .brand small {
    font-size: 8px;
  }
  .page-head.split {
    align-items: flex-start;
    flex-direction: column;
  }
  .stats {
    gap: 8px;
  }
  .stat {
    padding: 15px 10px;
  }
  .stat strong {
    font-size: 26px;
  }
  .stat span {
    font-size: 11px;
  }
  .editor-layout {
    display: flex;
    flex-direction: column;
  }
  .editor-side {
    position: static;
    width: 100%;
    order: -1;
  }
  .editor-side .field-settings {
    max-height: 300px;
    overflow: auto;
  }
  .preview-surface {
    width: 100%;
    padding: 12px;
  }
  .document-row {
    padding: 16px;
    gap: 14px;
  }
  .document-row h3 {
    font-size: 17px;
  }
  .document-row > .actions {
    grid-column: 1/-1;
  }
  .document-row .button,
  .document-row button {
    font-size: 12px;
  }
  .split {
    flex-wrap: wrap;
  }
  .two-col {
    grid-template-columns: 1fr;
  }
  .tabs button {
    padding: 13px;
  }
  .top-right {
    gap: 8px;
  }
  footer {
    flex-direction: column;
    gap: 8px;
  }
  .field-overlay {
    font-size: 9px;
  }
  .dev-banner {
    font-size: 10px;
  }
  .card {
    padding: 20px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  main {
    animation: enter 0.3s ease-out;
  }
  @keyframes enter {
    from {
      opacity: 0;
      transform: translateY(5px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}
@media print {
  header,
  footer,
  .dev-banner,
  .tabs,
  button {
    display: none !important;
  }
  main {
    padding: 0;
  }
  .card {
    break-inside: avoid;
  }
}
.signature-tools {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.signature-tools [hidden],
#sign-form label[hidden] {
  display: none !important;
}
#signature-pad {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3;
  background: white;
  border: 1px solid #8c857b;
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
}
#signature-image {
  display: block;
  width: 100%;
  max-height: 130px;
  object-fit: contain;
  padding: 12px;
  background: #fff;
  border: 1px solid #e4dcd0;
  border-radius: 8px;
}
.field-overlay .drawn-mark {
  position: static;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px 4px;
  pointer-events: none;
}
.signature-tools button {
  margin-top: 8px;
}
