:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d1d5db;
  --blue: #1e3a8a;
  --red: #c62828;
  --red-hover: #ab2222;
  --ok: #047857;
  --danger: #b42318;
  --shadow: 0 6px 22px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Montserrat", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.topbar {
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid #e5e7eb;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

.brand img {
  width: 78px;
  height: auto;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--blue);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 26px 24px 50px;
}

.card {
  background: var(--panel);
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
}

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

.grid-two {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

textarea {
  min-height: 105px;
  resize: vertical;
}

button {
  border: none;
  background: var(--red);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 200ms ease;
}

button:hover {
  background: var(--red-hover);
}

button.secondary {
  background: #e5e7eb;
  color: #111827;
}

button.secondary:hover {
  background: #d1d5db;
}

.status {
  min-height: 20px;
  margin: 4px 0 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--ok);
}

.table-wrap {
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.88rem;
}

th {
  font-size: 0.8rem;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #f9fafb;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: #f9fafb;
}

tr.selected {
  background: #eef3ff;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.history-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  background: #fcfcfd;
}

.history-item strong {
  color: var(--blue);
}

.history-grid {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 8px;
  font-size: 0.82rem;
}

.document-actions {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
}

.contract-signature-box {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}

.contract-signature-box textarea {
  min-height: 78px;
}

.action-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--blue);
  color: #fff;
}

.action-link:hover {
  background: #1e40af;
}

.action-link.disabled {
  pointer-events: none;
  opacity: 0.55;
}

.status-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.status-pill.signed {
  color: #065f46;
  background: #d1fae5;
}

.status-pill.unsigned {
  color: #991b1b;
  background: #fee2e2;
}

.inline-sample-link {
  margin-left: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
}

.inline-sample-link:hover {
  text-decoration: underline;
}

.action-btn {
  margin: 0;
}

.history-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.history-actions a {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--blue);
}

.history-actions a:hover {
  text-decoration: underline;
}

.document-upload {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
}

.doc-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.documents-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.document-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.document-item p {
  margin: 0 0 6px;
  font-size: 0.86rem;
}

.document-item .muted {
  font-size: 0.82rem;
}

.document-item .action-row {
  margin-top: 6px;
}

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

.login-card {
  width: min(460px, 100%);
}

.login-card .brand {
  justify-content: flex-start;
  margin-bottom: 8px;
}

.login-card h2 {
  margin: 0 0 14px;
  text-align: center;
}

.login-actions {
  margin-top: 16px;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .grid-two {
    grid-template-columns: 1fr;
  }

  .topbar-inner,
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .doc-form-row {
    grid-template-columns: 1fr;
  }
}
