:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar img { max-height: 32px; max-width: 160px; }
.topbar .brand { font-weight: 700; color: var(--primary); font-size: 18px; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.step-num {
  display: inline-flex; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; align-items: center; justify-content: center;
}
.step-num.done { background: var(--success); }

h1 { font-size: 20px; margin: 0 0 4px; word-break: break-word; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

.viewer { width: 100%; height: 60vh; min-height: 360px; border: 1px solid var(--border); border-radius: 8px; background: #fafafa; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.secondary { background: #eef2ff; color: var(--primary); }
.btn.link { background: none; color: var(--danger); padding: 8px; font-weight: 500; }

input[type=text], input[type=tel], textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px;
}
.otp-input { letter-spacing: .5em; text-align: center; font-size: 22px !important; max-width: 220px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.signers { list-style: none; padding: 0; margin: 0; }
.signers li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.signers li:last-child { border-bottom: 0; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: var(--muted); white-space: nowrap; }
.badge.SIGNED { background: #dcfce7; color: var(--success); }
.badge.REFUSED { background: #fee2e2; color: var(--danger); }
.badge.VIEWED { background: #fef3c7; color: var(--warning); }

.evidence { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.evidence:last-child { border-bottom: 0; }
.evidence .ok { color: var(--success); font-weight: 600; font-size: 13px; }
.evidence img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.evidence label.btn { padding: 8px 12px; font-size: 14px; }
.evidence input[type=file] { display: none; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 10px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.active { border-color: var(--primary); color: var(--primary); background: #eef2ff; }

.pad-wrap { position: relative; border: 2px dashed var(--border); border-radius: 10px; background: #fff; touch-action: none; }
#pad { width: 100%; height: 180px; display: block; cursor: crosshair; }
.pad-hint { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; color: #cbd5e1; pointer-events: none; font-size: 13px; }
.typed-preview { font-family: 'Brush Script MT', 'Segoe Script', cursive; font-size: 34px; padding: 14px; text-align: center; border: 1px solid var(--border); border-radius: 10px; min-height: 70px; margin-top: 8px; }

.terms { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin: 12px 0; }
.terms input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.info { background: #e0f2fe; color: #075985; }
.alert.success { background: #dcfce7; color: #166534; }

.center { text-align: center; }
.big-icon { font-size: 52px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 16px 40px; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }
