:root {
  --primary: #2155cd; --primary-dark: #173f9c; --bg: #f4f6fb; --card: #fff; --text: #1f2937;
  --muted: #6b7280; --border: #e5e7eb; --ok: #15803d; --warn: #b45309; --err: #b91c1c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 56px; background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar a { color: #fff; }
.brand { font-weight: 700; font-size: 20px; }
#nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
#nav a.active { text-decoration: underline; text-underline-offset: 6px; }
#nav .user { opacity: .85; font-size: 13px; }
main { max-width: 1250px; margin: 24px auto; padding: 0 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.narrow { max-width: 420px; margin: 40px auto; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 14px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 7px; font: inherit; background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
button, .btn { display: inline-block; padding: 9px 16px; border-radius: 7px; border: 1px solid var(--primary); background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button:hover, .btn:hover { background: var(--primary-dark); text-decoration: none; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary, .btn.secondary { background: #fff; color: var(--primary); }
button.secondary:hover { background: #eef2ff; }
button.danger { background: var(--err); border-color: var(--err); }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8fafc; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-em_andamento, .b-pendente { background: #fef3c7; color: var(--warn); }
.b-concluido, .b-assinado { background: #dcfce7; color: var(--ok); }
.b-rejeitado, .b-cancelado { background: #fee2e2; color: var(--err); }
.b-aguardando { background: #e5e7eb; color: #374151; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; }
.count { background: var(--err); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.progress { background: #e5e7eb; border-radius: 99px; height: 6px; width: 90px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.progress > div { background: var(--ok); height: 100%; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .doc-layout { grid-template-columns: 1fr; } }
.viewer { width: 100%; height: 80vh; border: 1px solid var(--border); border-radius: 8px; background: #525659; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border: 0; }
.step { width: 28px; height: 28px; border-radius: 50%; background: #e5e7eb; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.step.assinado { background: var(--ok); color: #fff; }
.step.pendente { background: #f59e0b; color: #fff; }
.step.rejeitado { background: var(--err); color: #fff; }
.sig-thumb { max-height: 40px; max-width: 140px; display: block; margin-top: 4px; }
.sigpad-wrap { border: 2px dashed #94a3b8; border-radius: 8px; background: #fff; touch-action: none; }
#sigpad { width: 100%; height: 160px; display: block; cursor: crosshair; }
.signers-list { list-style: none; padding: 0; margin: 8px 0; counter-reset: s; }
.signers-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; margin-bottom: 6px; background: #fafafa; }
.signers-list li::before { counter-increment: s; content: counter(s) "."; font-weight: 700; color: var(--primary); width: 22px; }
.signers-list.parallel li::before { content: "•"; }
.signers-list li span { flex: 1; }
.alert { padding: 10px 14px; border-radius: 7px; margin: 10px 0; }
.alert.error { background: #fee2e2; color: var(--err); }
.alert.ok { background: #dcfce7; color: var(--ok); }
.alert.info { background: #e0e7ff; color: var(--primary-dark); }
.toast { position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 420px; z-index: 100; }
.toast.error { background: var(--err); }
.hidden { display: none !important; }
.history { font-size: 13px; }
.history td { padding: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
