@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@600;700;800&family=Inter:wght@400;500;600&display=swap");

:root {
  --navy: #102f52;
  --navy-deep: #0b2240;
  --orange: #e07520;
  --orange-soft: #fbe9da;
  --offwhite: #f7f7f2;
  --ink: #1c2430;
  --muted: #5d6b7c;
  --line: #e2e4dd;
  --card: #ffffff;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --err: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 47, 82, 0.06), 0 12px 32px -16px rgba(16, 47, 82, 0.25);
  --font-head: "Manrope", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--offwhite);
  background-image: radial-gradient(1200px 500px at 80% -10%, rgba(224, 117, 32, 0.12), transparent 60%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); color: var(--navy); margin: 0 0 0.4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
p { line-height: 1.55; }
a { color: var(--navy); }
small, .muted { color: var(--muted); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; background: #eef0ea; padding: 1px 5px; border-radius: 4px; word-break: break-all; }

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 0 16px;
  height: 58px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; color: #fff; text-decoration: none; }
.topbar .brand .dot { width: 12px; height: 12px; border-radius: 3px; background: var(--orange); transform: rotate(45deg); }
.topbar .who { font-size: 0.85rem; opacity: 0.85; display: flex; gap: 12px; align-items: center; }
.topbar button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); }

main { max-width: 1080px; margin: 0 auto; padding: 28px 16px 64px; }
.grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.doc { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); } }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; border: 1px solid rgba(16,47,82,0.06); }
.card.accent { border-top: 4px solid var(--orange); }

label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--navy); margin: 12px 0 6px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="file"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--ink);
}
input:focus { outline: 2px solid rgba(224,117,32,0.45); border-color: var(--orange); }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 10px 16px; border: 1px solid transparent;
  background: var(--navy); color: #fff; transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -10px rgba(16,47,82,0.6); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary, button.primary { background: var(--orange); }
.btn-ghost, button.ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; border-radius: 12px; }

.signer-row { display: grid; grid-template-columns: 1fr 1.2fr 1fr auto; gap: 8px; align-items: end; margin-top: 8px; }
.signer-row label { margin-top: 0; }
@media (max-width: 700px) { .signer-row { grid-template-columns: 1fr; } }
.signer-row .remove { background: transparent; color: var(--err); border: 1px solid var(--line); padding: 10px 12px; }

.doc-list { display: flex; flex-direction: column; gap: 12px; }
.doc-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; transition: border-color 0.15s; }
.doc-item:hover { border-color: var(--orange); }
.doc-item h3 { margin: 0 0 4px; font-size: 1rem; }
.progress { height: 8px; background: #eceee7; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), #f09a52); border-radius: 99px; transition: width 0.6s cubic-bezier(.2,.8,.2,1); }
.counter { font-family: var(--font-head); font-weight: 800; font-size: 1.6rem; color: var(--navy); line-height: 1; }
.counter small { font-size: 0.8rem; font-weight: 600; color: var(--muted); display: block; margin-top: 4px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.pill.ok { background: #e3f4ea; color: var(--ok); }
.pill.pending { background: var(--orange-soft); color: #9a4e0f; }
.pill.err { background: #fde8e6; color: var(--err); }
.pill.neutral { background: #eef0ea; color: var(--muted); }

.signers { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.signers li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: #fafaf7; border: 1px solid var(--line); }
.signers li .name { font-weight: 600; }
.signers li .mail { font-size: 0.8rem; color: var(--muted); }

.notice { padding: 12px 14px; border-radius: 10px; font-size: 0.9rem; background: #fff; border: 1px solid var(--line); }
.notice.info { background: #eef4fb; border-color: #cfe0f5; color: #163c66; }
.notice.ok { background: #e3f4ea; border-color: #bfe3cc; color: #155c33; }
.notice.err { background: #fde8e6; border-color: #f5c2bd; color: #7a1a12; }
.notice.warn { background: #fff6e5; border-color: #f3dcae; color: #6b4a0e; }

.pdf-frame { width: 100%; height: min(70vh, 820px); border: 1px solid var(--line); border-radius: 12px; background: #e9ebe4; }

/* Signature pad */
.pad-wrap { position: relative; border: 2px dashed var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.pad-wrap.active { border-color: var(--orange); }
canvas.pad { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; }
.pad-hint { position: absolute; inset: auto 0 10px 0; text-align: center; color: var(--muted); font-size: 0.85rem; pointer-events: none; }
.pad-line { position: absolute; left: 10%; right: 10%; bottom: 56px; border-bottom: 1px solid #d8dbd2; pointer-events: none; }
.pad-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Sign ceremony */
.ceremony { text-align: center; padding: 20px 10px; }
.ceremony canvas.replay { width: min(100%, 420px); height: 180px; display: block; margin: 0 auto 8px; }
.stamp {
  display: inline-block; margin-top: 10px; padding: 8px 16px; border: 2px solid var(--ok); color: var(--ok); border-radius: 8px;
  font-family: var(--font-head); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.85rem;
  transform: rotate(-6deg) scale(0); opacity: 0;
}
.stamp.show { animation: stamp-in 0.5s cubic-bezier(.2,1.4,.3,1) forwards; }
@keyframes stamp-in { to { transform: rotate(-6deg) scale(1); opacity: 1; } }
.check { width: 64px; height: 64px; margin: 0 auto 10px; display: none; }
.check.show { display: block; }
.check circle { stroke: var(--ok); stroke-width: 3; fill: none; stroke-dasharray: 190; stroke-dashoffset: 190; animation: draw 0.6s ease forwards; }
.check path { stroke: var(--ok); stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.4s 0.5s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.key-badge { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 10px; background: #fafaf7; border: 1px solid var(--line); }
.key-badge img { height: 48px; max-width: 160px; object-fit: contain; background: #fff; border-radius: 6px; border: 1px solid var(--line); }
.key-badge .fp { font-size: 0.72rem; color: var(--muted); word-break: break-all; }

.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.space { justify-content: space-between; }
.mt { margin-top: 16px; }
footer { text-align: center; color: var(--muted); font-size: 0.78rem; margin-top: 40px; }
