:root {
  color-scheme: dark;
  --bg: #080c15;
  --panel: #111827;
  --line: #273449;
  --text: #ecf1fa;
  --muted: #a4b1c8;
  --green: #34d7a6;
  --blue: #83baff;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background:
    radial-gradient(ellipse at top right, #153332 0, transparent 48%), var(--bg);
  color: var(--text);
  font:
    15px/1.55 system-ui,
    -apple-system,
    sans-serif;
}
a {
  color: var(--blue);
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
.button {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: #1b273b;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover,
.button:hover {
  border-color: var(--green);
}
button:disabled {
  opacity: 0.45;
  cursor: wait;
}
button.primary {
  background: var(--green);
  color: #061b16;
  font-weight: 700;
}
.danger {
  color: #ffb4bc;
}
header {
  padding: 18px max(20px, calc((100vw - 1360px) / 2));
  border-bottom: 1px solid var(--line);
  background: #080c15dd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
header img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}
header .brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
header strong {
  display: block;
}
small,
.muted {
  color: var(--muted);
}
main {
  max-width: 1360px;
  margin: auto;
  padding: 34px 24px 70px;
}
h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.15;
  letter-spacing: -0.04em;
  margin: 8px 0 12px;
}
h2 {
  font-size: 21px;
  margin: 0 0 18px;
}
h3 {
  margin: 0 0 8px;
}
.eyebrow {
  color: var(--green);
  font-size: 12px;
  letter-spacing: 0.14em;
  font-weight: 700;
  text-transform: uppercase;
}
.head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.actions {
  justify-content: flex-start;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 26px 0;
}
.stat,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.stat strong {
  display: block;
  font-size: 30px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0;
}
.tabs button[aria-selected="true"] {
  background: #34d7a61b;
  border-color: var(--green);
  color: var(--green);
}
[hidden] {
  display: none !important;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.full {
  grid-column: 1/-1;
}
label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 5px;
}
input:not([type="checkbox"]),
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid #38465b;
  background: #080f1c;
  color: var(--text);
}
input[type="checkbox"] {
  accent-color: var(--green);
}
textarea {
  resize: vertical;
  min-height: 95px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
}
.help {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 12px;
}
.signature-preview {
  background: repeating-conic-gradient(#d8dde5 0% 25%, white 0% 50%) 50%/16px
    16px;
  border-radius: 10px;
  padding: 12px;
  width: min(100%, 360px);
  height: 110px;
  object-fit: contain;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 730px;
}
td,
th {
  padding: 14px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
}
.badge {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 12px;
}
.badge.signed,
.badge.paid {
  color: var(--green);
}
.badge.pending {
  color: #ffcf70;
}
.empty {
  padding: 40px;
  color: var(--muted);
  text-align: center;
}
#notice {
  padding: 12px 16px;
  background: #162c3a;
  border: 1px solid #38667d;
  border-radius: 10px;
  margin: 18px 0;
}
#notice.error {
  background: #331c2a;
  border-color: #8a3d53;
}
dialog {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  width: min(900px, 95vw);
  max-height: 92vh;
  padding: 24px;
}
dialog::backdrop {
  background: #000a;
}
.document {
  margin-top: 20px;
}
.agreement {
  background: white;
  color: #1b2839;
  border-radius: 10px;
  padding: 45px;
  font:
    14px/1.65 Georgia,
    serif;
}
.agreement h1 {
  font-size: 31px;
  letter-spacing: -0.02em;
}
.document-brand {
  font: 700 12px system-ui;
  letter-spacing: 0.15em;
  color: #186950;
}
.document-ref {
  font: 12px system-ui;
  color: #667085;
  border-bottom: 1px solid #dce1e7;
  padding-bottom: 20px;
}
.parties,
.signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 25px 0;
}
.agreement small {
  color: #586579;
  font: 700 12px system-ui;
}
.agreement section {
  margin: 22px 0;
}
.agreement h2 {
  font: 700 15px system-ui;
  margin: 0 0 8px;
}
.agreement p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 8px 0;
}
.signature-image {
  width: 240px;
  max-width: 100%;
  height: 90px;
  object-fit: contain;
  object-position: left;
}
.agreement .signatures section {
  break-inside: avoid;
  border-top: 1px solid #ccc;
  padding-top: 15px;
}
canvas.signature-pad {
  display: block;
  width: 100%;
  height: 170px;
  background: white;
  border: 1px solid #aaa;
  border-radius: 10px;
  touch-action: none;
}
#sign-page {
  max-width: 1000px;
}
.ack label {
  font-weight: 400;
  display: flex;
  gap: 10px;
  margin: 14px 0;
}
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.filters input {
  flex: 1;
}
.filters select {
  width: 170px;
}
@media (max-width: 700px) {
  main {
    padding: 24px 15px;
  }
  .grid,
  .parties,
  .signatures {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .stat {
    padding: 15px;
  }
  .stat strong {
    font-size: 24px;
  }
  header {
    padding: 15px;
    flex-wrap: wrap;
  }
  .agreement {
    padding: 24px 18px;
  }
  .filters {
    flex-wrap: wrap;
  }
  .filters select {
    width: 100%;
  }
}
@media print {
  :root {
    color-scheme: light;
    background: white;
  }
  body {
    background: white;
    color: black;
  }
  header,
  .no-print,
  #notice,
  .stats,
  .tabs,
  #sign-form {
    display: none !important;
  }
  main,
  #sign-page {
    padding: 0;
    max-width: none;
  }
  dialog:not(#viewer) {
    display: none !important;
  }
  dialog {
    overflow: visible;
    position: static;
    max-height: none;
    width: 100%;
    border: 0;
    padding: 0;
    background: white;
  }
  dialog::backdrop {
    display: none;
  }
  .agreement {
    padding: 0;
    border-radius: 0;
    font-size: 11pt;
  }
  .agreement h1 {
    font-size: 24pt;
  }
  .document {
    margin: 0;
  }
  body:has(dialog[open]) main {
    display: none;
  }
  .agreement h2 {
    break-after: avoid;
  }
  .parties,
  .signatures {
    grid-template-columns: 1fr 1fr;
  }
  .card {
    border: 0;
    padding: 0;
  }
  @page {
    size: A4;
    margin: 18mm;
  }
}
