:root {
  --brand: #0b5fff;
  --brand-dark: #0847c4;
  --ink: #1a2b4a;
  --muted: #5a6b85;
  --line: #e6ebf3;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(16, 40, 90, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar img { height: 30px; }
.topbar .sep { width: 1px; height: 26px; background: var(--line); }
.topbar .title { font-weight: 600; color: var(--muted); font-size: 15px; }

.wrap { max-width: 960px; margin: 0 auto; padding: 28px 20px 60px; }
.wrap.narrow { max-width: 720px; }
.wrap.wide { max-width: none; }

/* Layout 2 cột 50-50: form trái | lịch sử phải */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}
/* Cột phải dính theo khi cuộn (màn hình đủ cao) */
.col-right { position: sticky; top: 78px; }
@media (max-width: 940px) {
  .two-col { grid-template-columns: 1fr; }
  .col-right { position: static; }
}

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 22px;
}
.card h1 { font-size: 22px; margin: 0 0 4px; }
.card h2 { font-size: 17px; margin: 0 0 16px; }
.card .subtitle { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fbfcfe;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 95, 255, .12);
  background: #fff;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #eef2fb; color: var(--brand); }
.btn-ghost:hover { background: #e2e9fa; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 15px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; display: none; }
.alert.show { display: block; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-warn { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-signed { background: #dcfce7; color: #15803d; }
.badge-expired { background: #f1f5f9; color: #64748b; }

/* ---------- Legal document ---------- */
.doc { background: #fbfcfe; border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.doc h3 { margin: 0 0 10px; font-size: 15px; }
.doc p { font-size: 13.5px; color: #33415c; text-align: justify; margin: 0 0 14px; }
.doc .meta { display: flex; flex-wrap: wrap; gap: 8px 22px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px dashed var(--line); }
.doc .meta div { font-size: 13px; }
.doc .meta span { color: var(--muted); }
.doc .meta b { color: var(--ink); }

/* ---------- Signature ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab { padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.sig-pane { display: none; }
.sig-pane.active { display: block; }
.sig-canvas-box { position: relative; border: 2px dashed #c3ccdb; border-radius: 12px; background: #fff; }
#sigCanvas { width: 100%; height: 200px; display: block; touch-action: none; cursor: crosshair; }
.sig-canvas-box .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #b9c2d4; font-size: 14px; pointer-events: none; }
.sig-upload-box { border: 2px dashed #c3ccdb; border-radius: 12px; padding: 26px; text-align: center; background: #fff; }
.sig-upload-box img { max-height: 150px; max-width: 100%; margin-top: 12px; }
.sig-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.link-btn { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; font-weight: 600; }

/* ---------- Choice (radio pills) ---------- */
.choice { display: flex; gap: 12px; }
.choice label { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; font-size: 13.5px; display: flex; gap: 9px; align-items: center; }
.choice label:has(input:checked) { border-color: var(--brand); background: #f0f5ff; }
.choice input { width: auto; }

/* ---------- Table (dashboard) ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: #fafbff; }
.copy-link { color: var(--brand); cursor: pointer; font-weight: 600; font-size: 12.5px; background: none; border: none; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* ---------- Result box ---------- */
.result-link { display: flex; gap: 8px; margin-top: 10px; }
.result-link input { flex: 1; font-family: monospace; font-size: 13px; }

/* ---------- Success screen ---------- */
.center-screen { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.success-card { text-align: center; max-width: 480px; }
.success-icon { width: 64px; height: 64px; border-radius: 50%; background: #dcfce7; color: var(--ok); display: flex; align-items: center; justify-content: center; font-size: 34px; margin: 0 auto 18px; }
.muted { color: var(--muted); font-size: 14px; }
