:root {
  --bg-main: #f4f2ec;
  --bg-card: rgba(255, 255, 255, 0.82);
  --text-main: #1f2933;
  --text-sub: #536171;
  --accent: #0b6e4f;
  --accent-strong: #07533b;
  --danger: #a32638;
  --warn: #9a6700;
  --ok: #12613a;
  --border: #dde2e8;
  --shadow: 0 12px 30px rgba(13, 38, 59, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Tajawal", sans-serif;
  background:
    radial-gradient(circle at 20% -10%, #d7efe4 0%, transparent 40%),
    radial-gradient(circle at 80% -20%, #f7dbc6 0%, transparent 36%),
    var(--bg-main);
  color: var(--text-main);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 68px 24px 56px;
  background: linear-gradient(140deg, #133d52, #0b6e4f 55%, #ca4f32);
  color: #fff;
}

.hero-pattern {
  position: absolute;
  inset: -30%;
  background-image: linear-gradient(
    60deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0) 25%,
    rgba(255, 255, 255, 0) 50%,
    rgba(255, 255, 255, 0.04) 50%,
    rgba(255, 255, 255, 0.04) 75%,
    rgba(255, 255, 255, 0) 75%
  );
  background-size: 28px 28px;
  animation: drift 18s linear infinite;
}

@keyframes drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(42px);
  }
}

.hero-content {
  max-width: 900px;
  margin-inline: auto;
  position: relative;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.auth-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 220px;
}

.auth-user {
  margin: 0;
  font-weight: 700;
}

.eyebrow {
  font-weight: 700;
  margin: 0 0 8px;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 14px;
}

.hero-sub {
  margin: 0;
  max-width: 700px;
  line-height: 1.6;
}

.layout,
.signer-layout {
  width: min(1150px, 94%);
  margin-inline: auto;
  margin-top: -28px;
  padding-bottom: 42px;
  display: grid;
  gap: 16px;
}

.card {
  backdrop-filter: blur(6px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
}

.section-title span {
  color: var(--text-sub);
  font-size: 0.95rem;
}

.section-title.compact {
  margin-top: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full {
  grid-column: 1 / -1;
}

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

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text-main);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #0b6e4f;
  box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.15);
}

.signers-stack {
  display: grid;
  gap: 10px;
}

.signer-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.signer-row .full {
  grid-column: 1 / -1;
}

.remove-btn {
  justify-self: start;
  background: transparent;
  border: 1px solid #c4ccd7;
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
}

.actions-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hint {
  color: var(--text-sub);
}

.primary-btn,
.ghost-btn,
.danger-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 15px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #0f8a62);
  color: #fff;
}

.ghost-btn {
  background: #fff;
  border: 1px solid #cfd8e3;
  color: var(--text-main);
}

.danger-btn {
  background: linear-gradient(135deg, var(--danger), #bd3045);
  color: #fff;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.remove-btn:hover {
  transform: translateY(-1px);
}

.feedback {
  min-height: 22px;
  margin: 12px 0 0;
  font-weight: 700;
}

.feedback.ok {
  color: var(--ok);
}

.feedback.warn {
  color: var(--warn);
}

.feedback.err {
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: right;
  vertical-align: top;
}

th {
  color: var(--text-sub);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.badge.pending {
  background: #fff2cc;
  color: #7f5600;
}

.badge.completed {
  background: #d8f5e7;
  color: #0d5a37;
}

.badge.rejected {
  background: #ffe3e7;
  color: #8f1f30;
}

.details-panel {
  margin-top: 14px;
  border: 1px dashed #b8c4d0;
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfe;
}

.hidden {
  display: none;
}

.details-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.details-grid section {
  border: 1px solid #dbe3eb;
  border-radius: 10px;
  padding: 10px;
}

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

.outbox-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.outbox-item p {
  margin: 4px 0;
}

.signer-layout {
  margin-top: 24px;
}

.auth-card {
  max-width: 520px;
  margin-inline: auto;
}

.signer-info {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

#document-frame {
  width: 100%;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.signer-form {
  margin-top: 12px;
}

.delegate-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #dbe3eb;
  border-radius: 12px;
  background: #fff;
}

.delegate-box h3 {
  margin: 0 0 10px;
}

.delegate-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.delegate-grid button {
  grid-column: 1 / -1;
  justify-self: start;
}

@media (max-width: 840px) {
  .form-grid,
  .signer-row,
  .details-grid,
  .delegate-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-box {
    align-items: stretch;
  }

  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }
}
