/* Aprovo — white label minimalista (preto/cinza/branco) */
:root {
  --ink: #1a1a1a;
  --gray-900: #262626;
  --gray-700: #525252;
  --gray-500: #8a8a8a;
  --gray-300: #d4d4d4;
  --gray-200: #e7e7e7;
  --gray-100: #f4f4f4;
  --white: #ffffff;
  --accent: #1a1a1a;
  --danger: #b3261e;
  --ok: #2e6b4f;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--gray-100);
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; text-decoration: none; }
.brand-logo { height: 30px; width: auto; max-width: 110px; object-fit: contain; }
.topbar-center { display: flex; gap: 4px; }
.nav-item {
  text-decoration: none; color: var(--gray-700);
  padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 14px;
}
.nav-item:hover { background: var(--gray-100); color: var(--ink); }
.nav-item.active { background: var(--ink); color: var(--white); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { color: var(--gray-700); font-size: 13px; }

/* ---------- Painel ---------- */
.panel-body { max-width: 1120px; margin: 28px auto; padding: 0 24px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.3px; }

/* ---------- Alertas ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: #eaf3ee; color: var(--ok); border: 1px solid #d3e5db; }
.alert-err { background: #fbeaea; color: var(--danger); border: 1px solid #f1d5d2; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--white);
  border: 1px solid var(--ink); border-radius: 999px;
  padding: 10px 22px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: #000; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--gray-700); border-color: var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); color: var(--ink); }
.btn-outline { background: var(--white); color: var(--ink); border-color: var(--gray-300); }
.btn-outline:hover { border-color: var(--ink); }
.btn-danger { background: var(--white); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ---------- Cards / tabelas ---------- */
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 20px; }
table.data { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--gray-200); }
table.data th { text-align: left; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--gray-500); background: var(--gray-100); padding: 12px 16px; border-bottom: 1px solid var(--gray-200); }
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--gray-200); font-size: 14px; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafafa; }

.badge { display: inline-block; padding: 2px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-outline { border: 1px solid var(--gray-300); color: var(--gray-700); }
.badge-dark { background: var(--ink); color: #fff; }
.badge-ok { background: var(--ok); color: #fff; }
.badge-err { background: var(--danger); color: #fff; }

/* ---------- Formulários ---------- */
label.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%; background: var(--white);
  border: 1px solid var(--gray-300); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; color: var(--ink);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
textarea { min-height: 110px; resize: vertical; }
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); }

/* ---------- Drag & drop ---------- */
.dropzone {
  border: 2px dashed var(--gray-300); border-radius: var(--radius);
  background: #fbfbfb; padding: 48px 24px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--ink); background: var(--gray-100); }
.dropzone svg { display: block; margin: 0 auto 12px; }
.dropzone .dz-title { font-size: 16px; font-weight: 600; }
.dropzone .dz-sub { font-size: 12px; color: var(--gray-500); margin-top: 6px; }
.dropzone .dz-max { font-size: 12px; color: var(--gray-500); margin-top: 14px; display: flex; justify-content: space-between; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.doc-stage { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 18px; }
.page-wrap { position: relative; display: inline-block; max-width: 100%; }
.page-wrap img { display: block; max-width: 100%; height: auto; }
.field-box {
  position: absolute; border: 2px solid var(--ink); background: rgba(26,26,26,.06);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--ink); cursor: pointer;
  user-select: none;
}
.field-box .fx { position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: #fff; border: none; font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.field-box.initials { border-color: var(--gray-500); background: rgba(138,138,138,.08); }

.sidebar-panel { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px; position: sticky; top: 76px; }
.sidebar-panel h3 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.field-palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.palette-btn {
  background: var(--gray-100); border: 1px dashed var(--gray-300); border-radius: 8px;
  padding: 14px 6px; font-size: 13px; font-weight: 600; cursor: pointer; text-align: center;
}
.palette-btn:hover { border-color: var(--ink); background: #fff; }
.palette-btn.active { border-style: solid; border-color: var(--ink); background: var(--ink); color: #fff; }

/* ---------- Página pública (login / signatário) ---------- */
.pub {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--white); padding: 24px;
}
.pub-card { width: 100%; max-width: 420px; text-align: center; }
.pub-card .pub-logo { height: 52px; max-width: 220px; object-fit: contain; margin-bottom: 26px; }
.pub-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.pub-card p { color: var(--gray-700); font-size: 14px; margin-bottom: 22px; }
.pub-card form { text-align: left; }
.pub-card .btn { width: 100%; margin-top: 6px; }

/* Token: letras pré-preenchidas + caixas */
.token-row { display: flex; gap: 8px; justify-content: center; margin: 18px 0 24px; align-items: center; }
.token-fixed {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 22px; font-weight: 700; letter-spacing: 2px;
  border: 1px solid var(--gray-300); border-radius: 8px;
  padding: 12px 10px; min-width: 74px; text-align: center; background: var(--gray-100); color: var(--gray-700);
}
.token-dash { font-weight: 700; color: var(--gray-500); font-size: 20px; }
.token-box {
  width: 48px; height: 52px; text-align: center;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 22px; font-weight: 700;
  border: 1px solid var(--gray-300); border-radius: 8px;
  background: var(--white);
}
.token-box:focus { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }
.empty-state svg { margin: 0 auto 14px; opacity: .5; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.small { font-size: 12px; color: var(--gray-500); }
.muted { color: var(--gray-500); }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .two-col, .form-grid { grid-template-columns: 1fr; } }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--white); border-radius: 14px; padding: 26px; max-width: 520px; width: 92%; max-height: 88vh; overflow-y: auto; }
.modal h2 { font-size: 18px; margin-bottom: 14px; }

/* Spinner */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Viewer do signatário */
.sign-stage { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 18px; text-align: center; max-width: 900px; margin: 0 auto; }
.sign-stage img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.clickable-zone { position: absolute; border: 2px dashed var(--ink); border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--ink); background: rgba(26,26,26,.05); }
.clickable-zone.done { border-style: solid; background: transparent; }
.clickable-zone.done img { max-width: 100%; max-height: 100%; }
