@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Big+Shoulders+Display:wght@700;800&family=Space+Mono&family=Dancing+Script:wght@600&family=Caveat:wght@600&family=Great+Vibes&display=swap');

:root {
  --ink: #050505;
  --ink-2: #101013;
  --ink-3: #17171c;
  --lime: #c0ee4e;
  --lime-2: #afd637;
  --bg: #f3f3ee;
  --panel: #ffffff;
  --line: #e3e3dc;
  --muted: #6b6b66;
  --text: #111111;
  --danger: #d9443a;
  --warn: #e79b1a;
  --ok: #2f9e44;
  --radius: 10px;
  --body: 'Space Grotesk', system-ui, sans-serif;
  --display: 'Big Shoulders Display', Impact, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-family: var(--display); font-size: 40px; letter-spacing: 0.5px; text-transform: uppercase; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
[hidden] { display: none !important; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  height: 60px; padding: 0 24px;
  background: var(--ink); color: #fff;
}
.brand { display: flex; gap: 8px; align-items: baseline; text-decoration: none; font-family: var(--display); font-size: 24px; letter-spacing: 1px; }
.brand b { color: var(--lime); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { text-decoration: none; padding: 8px 12px; border-radius: 6px; color: #bdbdb6; font-size: 14px; }
.topbar nav a:hover { color: #fff; }
.topbar nav a.on { color: var(--ink); background: var(--lime); }

/* ---------- botões e formulários ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 8px; border: 1px solid transparent;
  background: var(--lime); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .05s;
}
button:hover, .btn:hover { background: var(--lime-2); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.dark, .btn.dark { background: var(--ink); color: #fff; }
button.dark:hover, .btn.dark:hover { background: var(--ink-3); }
button.ghost, .btn.ghost { background: transparent; border-color: var(--line); color: inherit; }
button.ghost:hover, .btn.ghost:hover { background: rgba(0,0,0,.04); }
.topbar button.ghost { border-color: #333; color: #ddd; }
button.danger { background: transparent; color: var(--danger); border-color: #f0c9c5; }
button.danger:hover { background: #fdf0ee; }
button.small, .btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
button.icon { width: 32px; height: 32px; padding: 0; }

label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], textarea, select {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--lime); outline-offset: 0; border-color: var(--ink); }
textarea { resize: vertical; min-height: 70px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--ink); }

/* ---------- layout geral ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 36px 24px 80px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.row { display: flex; gap: 12px; align-items: center; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }

/* ---------- painel ---------- */
.hero { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.hero p { margin: 6px 0 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stat { padding: 16px 18px; cursor: pointer; }
.stat.on { outline: 2px solid var(--ink); }
.stat b { display: block; font-family: var(--display); font-size: 34px; line-height: 1; }
.stat span { font-size: 13px; color: var(--muted); }
.list { overflow: hidden; }
.item { display: grid; grid-template-columns: 1fr 220px 120px 110px; gap: 16px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); text-decoration: none; }
.item:first-child { border-top: 0; }
.item:hover { background: #fafaf6; }
.item .t { font-weight: 600; }
.item .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.search { max-width: 280px; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-draft { background: #ececE6; color: #555; }
.st-sent { background: #fff2d6; color: #8a5a00; }
.st-done { background: #e3f6c9; color: #2c5a00; }
.st-declined { background: #fde3e0; color: #9b2118; }
.st-void { background: #ececec; color: #777; text-decoration: line-through; }

/* ---------- modais ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5,5,5,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .box { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 14px; padding: 24px; }
.modal .box h2 { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 34px 16px; text-align: center; cursor: pointer; background: #fafaf6; }
.drop.over, .drop:hover { border-color: var(--ink); background: #f5fbe6; }
.drop b { display: block; margin-bottom: 4px; }

/* ---------- editor (preparar) ---------- */
.editor { display: grid; grid-template-columns: 290px 1fr 270px; height: calc(100vh - 60px); }
.side { background: #fff; border-right: 1px solid var(--line); overflow: auto; padding: 18px; }
.side.right { border-right: 0; border-left: 1px solid var(--line); }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 18px 0 10px; }
.side h3:first-child { margin-top: 0; }
.viewer { overflow: auto; padding: 24px 16px 80px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.editbar { display: flex; gap: 10px; align-items: center; padding: 0 16px; height: 56px; background: #fff; border-bottom: 1px solid var(--line); }
.editbar input.title { border-color: transparent; font-weight: 600; font-size: 16px; max-width: 420px; }
.editbar input.title:hover { border-color: var(--line); }
.editor-shell { display: flex; flex-direction: column; }
.editor-shell .editor { height: calc(100vh - 116px); }

.signer { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.signer.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.signer .dot { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ink); margin-top: 6px; }
.signer .fields { flex: 1; display: grid; gap: 6px; }
.signer input { padding: 7px 9px; font-size: 13.5px; }
.signer button { margin-top: 4px; }

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: grab; user-select: none; background: #fff; }
.tool:hover { border-color: var(--ink); }
.tool.armed { background: var(--ink); color: #fff; }
.tool i { font-style: normal; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; font-size: 12px; background: var(--c, var(--lime)); color: var(--ink); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

.page { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.06); flex: 0 0 auto; }
.page canvas { display: block; }
.page .layer { position: absolute; inset: 0; }
.page-num { position: absolute; right: -2px; bottom: -22px; font-size: 11.5px; color: var(--muted); }
.viewer.armed .layer { cursor: crosshair; }

.fld {
  position: absolute; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 30%, transparent);
  border-radius: 4px; font-size: 11.5px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 4px; overflow: hidden;
  user-select: none; touch-action: none;
}
.editor .fld { cursor: move; }
.fld.sel { outline: 2px solid var(--ink); outline-offset: 1px; z-index: 2; }
.fld .del { position: absolute; top: -1px; right: -1px; width: 18px; height: 18px; border-radius: 0 3px 0 6px; background: var(--ink); color: #fff; font-size: 11px; display: none; place-items: center; cursor: pointer; }
.fld.sel .del { display: grid; }
.fld .rs { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--ink) 50%); }
.fld .lb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; pointer-events: none; }

.props .empty-note { color: var(--muted); font-size: 13.5px; }
.props > * + * { margin-top: 14px; }
.summary-list { font-size: 13.5px; }
.summary-list div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }

/* ---------- detalhe ---------- */
.grid2 { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; align-items: start; }
.section { padding: 20px; }
.section h2 { margin-bottom: 14px; }
.srow { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.srow:first-of-type { border-top: 0; }
.srow .who { flex: 1; min-width: 160px; }
.srow .who b { display: block; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.timeline li { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.timeline li.done::before { background: var(--lime); box-shadow: 0 0 0 2px var(--ink); }
.timeline li small { display: block; color: var(--muted); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.mini-viewer { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px; background: #e9e9e3; border-radius: 10px; max-height: 76vh; overflow: auto; }

/* ---------- assinatura ---------- */
.signbar { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; padding: 12px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.signbar .brand { font-size: 20px; }
.signbar .msg { flex: 1; min-width: 200px; font-size: 14px; color: #ddd; }
.signbar .msg b { color: #fff; }
.progress { font-family: var(--mono); font-size: 12.5px; color: var(--lime); }
.sign-viewer { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 26px 12px 120px; }
.sign-viewer .fld { cursor: default; overflow: visible; }
.sign-viewer .fld.mine { cursor: pointer; animation: pulse 2s infinite; background: color-mix(in srgb, var(--c) 45%, transparent); }
.sign-viewer .fld.mine.filled { animation: none; background: transparent; border-style: dashed; border-color: color-mix(in srgb, var(--c) 80%, #000); }
.sign-viewer .fld.other { opacity: .45; }
.sign-viewer .fld.done { border-color: transparent; background: transparent; opacity: 1; }
.fld img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.fld .val { font-family: var(--body); font-weight: 500; color: #0d1f6b; white-space: nowrap; overflow: hidden; padding: 0 3px; width: 100%; text-align: left; }
.fld input.inline { width: 100%; height: 100%; border: 0; background: transparent; padding: 0 4px; font-size: inherit; border-radius: 0; color: #0d1f6b; }
.fld input.inline:focus { outline: none; background: rgba(255,255,255,.7); }
.fld .req { position: absolute; top: -2px; left: 2px; color: var(--danger); font-size: 13px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 70%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }
.next-tag { position: absolute; transform: translate(-100%, -50%); left: -8px; top: 50%; background: var(--ink); color: var(--lime); font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 4px; white-space: nowrap; pointer-events: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: transparent; color: var(--muted); border-radius: 0; border-bottom: 2px solid transparent; height: 38px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.pad { width: 100%; height: 180px; border: 1px solid var(--line); border-radius: 10px; background: #fff; touch-action: none; display: block; cursor: crosshair; }
.pad.small { height: 120px; }
.font-choice { display: grid; gap: 8px; margin-top: 10px; }
.font-choice label { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; cursor: pointer; font-size: 30px; font-weight: 400; color: #0d1f6b; min-height: 62px; }
.font-choice input { accent-color: var(--ink); }
.adopt-preview { display: flex; gap: 12px; }
.adopt-preview > div { flex: 1; }

.center-card { max-width: 520px; margin: 60px auto; padding: 32px; text-align: center; }
.center-card .big { font-size: 46px; margin-bottom: 8px; }
.otp { font-family: var(--mono); font-size: 28px; letter-spacing: 10px; text-align: center; }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 14px; z-index: 99; transition: .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }

/* ---------- celular ---------- */
@media (max-width: 1000px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .editor-shell .editor { height: auto; }
  .side, .side.right { border: 0; border-bottom: 1px solid var(--line); }
  .viewer { min-height: 70vh; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .topbar nav a { padding: 6px 8px; font-size: 13px; }
  .wrap { padding: 24px 16px 60px; }
  h1 { font-size: 32px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .item { grid-template-columns: 1fr auto; }
  .item .hide-sm { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .signbar { padding: 10px 16px; gap: 8px; }
  .signbar .msg { display: none; }
  .signbar .brand { font-size: 17px; flex: 1; }
  .signbar button { height: 34px; padding: 0 11px; font-size: 13px; }
  .signbar #finishBtn { margin-left: auto; }
  .next-tag { display: none; }
}
