/* MOOPE Assinatura — Design system A6
   Dark mode preparado via [data-theme="dark"] — não ativado nesta fase. */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --bg: #f4f6f8;
  --bg-elev: #ffffff;
  --ink: #12151c;
  --muted: #5c6573;
  --line: #e4e8ee;
  --line-strong: #cfd6e0;
  --brand: #0f3d3e;
  --brand-2: #1a6b6c;
  --accent: #0f766e;
  --accent-soft: #e7f4f3;
  --ok: #0f7a43;
  --ok-soft: #e8f6ee;
  --warn: #9a6700;
  --warn-soft: #fff6e5;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info: #175cd3;
  --info-soft: #eff4ff;
  --shadow: 0 1px 2px rgba(18, 21, 28, 0.06), 0 8px 24px rgba(18, 21, 28, 0.04);
  --radius: 14px;
  --radius-sm: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --sidebar: 248px;
  --header: 56px;
  --nav-h: 64px;
  --focus: 0 0 0 3px rgba(15, 118, 110, 0.28);
  --st-draft: #667085;
  --st-ready: #175cd3;
  --st-wait: #b54708;
  --st-part: #c4320a;
  --st-fin: #6941c6;
  --st-done: #087443;
  --st-decl: #b42318;
  --st-canc: #667085;
  --st-exp: #b54708;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --bg-elev: #171b22;
  --ink: #eef1f6;
  --muted: #9aa3b2;
  --line: #2a3140;
  --brand: #9ee1e0;
  --accent: #2dd4bf;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 0;
}
h1, h2, h3 { letter-spacing: -0.03em; font-weight: 650; margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }

.skip {
  position: absolute; left: -999px; top: 8px;
}
.skip:focus { left: 8px; background: #fff; padding: 8px 12px; z-index: 80; }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.sidebar { display: none; }
.brand {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.72;
  margin-bottom: 18px;
  padding: 0 10px;
}
.brand strong { display: block; font-size: 1.05rem; letter-spacing: -0.03em; text-transform: none; opacity: 1; color: #fff; margin-top: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  color: #d5e8e8; text-decoration: none;
  padding: 10px 12px; border-radius: 10px;
}
.nav-link[aria-current="page"], .nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-ico { width: 18px; text-align: center; opacity: 0.85; }
.sidebar-grow { flex: 1; min-height: 8px; }

.main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.header {
  height: var(--header);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.header-brand {
  font-weight: 700; font-size: .95rem; color: var(--brand); text-decoration: none;
  white-space: nowrap;
}
.search { display: none; flex: 1; max-width: 420px; position: relative; }
.search input {
  width: 100%; border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 14px 10px 36px; background: var(--bg); font-size: 16px;
}
.search .ico { position: absolute; left: 12px; top: 10px; color: var(--muted); }
.search-open {
  position: absolute; left: 8px; right: 8px; top: 8px;
  display: block; max-width: none; z-index: 25;
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.search-btn { display: inline-flex; }
.icon-btn {
  border: 0; background: transparent; width: 44px; height: 44px; border-radius: 10px; cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--bg); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; cursor: pointer; border: 0;
}
.content { padding: 16px 16px 32px; max-width: 1120px; width: 100%; }
.crumb { color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }
.crumb a { color: inherit; text-decoration: none; }
.crumb a:hover { color: var(--accent); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.grid { display: grid; gap: 12px; }
.grid.stats { grid-template-columns: 1fr 1fr; }
.grid-2, .split, .grid-form { display: grid; gap: 12px; grid-template-columns: 1fr; }
.page-head { display: flex; flex-direction: column; gap: 12px; }
.page-head .btn { width: 100%; }
.stat .k { color: var(--muted); font-size: 0.82rem; }
.stat .v { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.04em; margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
  background: var(--ink); color: #fff; text-decoration: none;
  min-height: 44px; min-width: 44px;
}
.btn:hover { filter: brightness(1.08); }
.btn-accent { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--bad); }
.btn-sm { padding: 7px 12px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 12px; background: #fff; font-size: 16px;
}
.textarea { min-height: 96px; resize: vertical; }
.label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 14px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; min-width: 480px; }
.table th { text-align: left; font-size: 0.75rem; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr { cursor: pointer; }
.table tr:hover td { background: #fafbfc; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 650; padding: 4px 8px; border-radius: 999px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-DRAFT { color: var(--st-draft); background: #f2f4f7; }
.st-READY { color: var(--st-ready); background: var(--info-soft); }
.st-AWAITING_SIGNATURES { color: var(--st-wait); background: var(--warn-soft); }
.st-PARTIALLY_SIGNED { color: var(--st-part); background: #fff4ed; }
.st-FINALIZING { color: var(--st-fin); background: #f4ebff; }
.st-COMPLETED { color: var(--st-done); background: var(--ok-soft); }
.st-DECLINED { color: var(--st-decl); background: var(--bad-soft); }
.st-CANCELLED { color: var(--st-canc); background: #f2f4f7; }
.st-EXPIRED { color: var(--st-exp); background: var(--warn-soft); }
.st-PREPARING { color: var(--info); background: var(--info-soft); }
.st-AVAILABLE, .st-INVITED, .st-VIEWED, .st-TERMS_ACCEPTED, .st-AWAITING_AUTHENTICATION, .st-COLLECTING_EVIDENCE { color: var(--st-wait); background: var(--warn-soft); }
.st-SIGNED { color: var(--st-done); background: var(--ok-soft); }
.st-PENDING { color: var(--st-draft); background: #f2f4f7; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; overflow: visible; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 12px; cursor: pointer; color: var(--muted);
  flex: 0 0 auto; min-height: 36px;
}
.chip-sm {
  padding: 4px 8px; min-height: 28px; font-size: .72rem; font-weight: 650;
  border-color: transparent;
}
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip-sm[aria-pressed="true"] { box-shadow: 0 0 0 2px currentColor; border-color: currentColor; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { width: 88px; height: 88px; margin-bottom: 12px; opacity: 0.85; }

.skeleton { background: linear-gradient(90deg, #eee, #f7f7f7, #eee); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.timeline { border-left: 2px solid var(--line); margin: 8px 0 0 12px; padding-left: 20px; }
.tl-item { position: relative; padding: 0 0 22px; }
.tl-item::before {
  content: ""; position: absolute; left: -27px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent-soft);
}
.tl-item .when { color: var(--muted); font-size: 0.78rem; }

.signer-card { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  padding: 28px 16px; text-align: center; background: #fafbfc; color: var(--muted);
  min-height: 88px;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.ok { color: var(--ok); }
.stack label { display: block; margin: 0 0 10px; }
.stack input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }

.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; overflow: visible; }
.step {
  font-size: 0.8rem; color: var(--muted); padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  white-space: nowrap; flex: 0 0 auto;
}
.step.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.menu {
  position: absolute; right: 16px; top: 58px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); min-width: 220px; padding: 8px; z-index: 30;
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; color: var(--ink); text-decoration: none;
}
.menu a:hover, .menu button:hover { background: var(--bg); }
.toast {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff;
  padding: 12px 16px; border-radius: 12px; z-index: 50;
}
.dialog-back {
  position: fixed; inset: 0; background: rgba(18,21,28,.4); display: grid; align-items: end; z-index: 40;
}
.dialog {
  background: #fff; border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  width: 100%; box-shadow: var(--shadow);
}
.err { color: var(--bad); min-height: 1.2em; }
.okmsg { color: var(--ok); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions > .btn { flex: 1 1 auto; }
.wizard-actions {
  position: sticky; z-index: 15;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex; gap: 8px; margin-top: 16px;
  padding: 12px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 12px);
}
.wizard-actions .btn { flex: 1; }
.pdf-box { margin-top: 16px; }
.pdf-frame { width: 100%; height: 42vh; min-height: 200px; border: 1px solid var(--line); border-radius: 12px; background: #525659; }
.pdf-toolbar { display:flex; justify-content:space-between; align-items:center; gap:8px; margin:8px 0; font-size:.85rem; color:var(--muted); }
.pdf-pages { max-height:min(62vh, 560px); overflow:auto; background:#e8eaed; border:1px solid var(--line); border-radius:12px; padding:8px; -webkit-overflow-scrolling:touch; }
.pdf-pages canvas { display:block; width:100%; height:auto; margin:0 auto 10px; background:#fff; border-radius:8px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0; }
.photo-prev { display:none; max-width:100%; border-radius:12px; margin-top:12px; }
.pdf-dialog { width: 100%; max-height: 96dvh; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
.pdf-dialog .pdf-frame { height: 70dvh; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 12px; }
.hint-box { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; }
.hint-box p { margin: 0 0 8px; }
.hint-box p:last-child { margin: 0; }
.signer-ok { border-left: 4px solid var(--ok); }
.signer-form { margin-top: 16px; padding-top: 8px; }
.check-line { display: flex; gap: 8px; align-items: center; color: var(--ink); }
.mode-cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
.mode-card { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; background: #fff; }
.mode-card.on { border-color: var(--accent); background: var(--accent-soft); }
.mode-card input { margin-right: 8px; }
.mode-card p { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }
.order-vis { display: flex; flex-direction: column; gap: 8px; }
.order-vis.parallel { flex-direction: row; flex-wrap: wrap; }
.order-pill { background: var(--accent-soft); color: var(--brand); padding: 10px 14px; border-radius: 12px; }

.policy-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer;
  background: var(--bg-elev); text-align: left; width: 100%;
}
.policy-card.on { border-color: var(--accent); box-shadow: var(--focus); background: var(--accent-soft); }
.otp-row { display: flex; gap: 6px; justify-content: space-between; }
.otp-box {
  width: 100%; flex: 1; min-width: 0; max-width: 48px; height: 48px; text-align: center; font-size: 1.25rem;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #fff;
}
.canvas-wrap {
  border: 1px dashed var(--line-strong); border-radius: 12px; background: #fff; touch-action: none;
}
.icp-face { display: flex; gap: 14px; align-items: center; }
.icp-selo { width: 88px; height: 88px; flex: 0 0 88px; object-fit: contain; }
.icp-face-copy { min-width: 0; }
.icp-face-copy .sec-badge { margin: 0 0 4px; }
.icp-face-copy strong { display: block; margin: 4px 0 2px; }
.sec-badge {
  display: inline-block; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--brand); border: 1px solid var(--accent);
  border-radius: 999px; padding: 4px 10px; margin: 8px 0 16px;
}
.cert-card { display: flex; gap: 12px; align-items: flex-start; margin-top: 10px; cursor: pointer; }
.type-card {
  display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 8px 0; cursor: pointer;
}
.type-card strong { display: block; margin-bottom: 6px; }
.type-card span { color: var(--muted); font-size: .9rem; }
.type-card.on { border-color: var(--accent); background: var(--accent-soft); }
.type-card.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.dialog-backdrop { position: fixed; inset: 0; background: rgba(18,21,28,.45); z-index: 40; padding: 16px; }
.signer-shell { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(80px + env(safe-area-inset-bottom)); width: 100%; overflow-x: hidden; }
.signer-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.progress-bar { display: flex; gap: 6px; margin: 8px 0 16px; }
.progress-bar span { flex: 1; height: 4px; background: var(--line); border-radius: 99px; }
.progress-bar span.on { background: var(--accent); }
.success-hero { text-align: center; padding: 28px 8px; }
.success-hero h1 { font-size: 1.8rem; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: stretch; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 4px 4px env(safe-area-inset-bottom);
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(18, 21, 28, 0.06);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 44px; min-width: 44px;
  color: var(--muted); text-decoration: none; background: none; border: 0;
  font-size: .68rem; font-weight: 650; cursor: pointer; border-radius: 10px;
}
.bn-item[aria-current="page"], .bn-item:hover { color: var(--accent); background: var(--accent-soft); }
.bn-ico { font-size: 1.15rem; line-height: 1; }
.bn-cta { color: #fff; background: var(--accent); margin: 4px 2px; border-radius: 14px; }
.bn-cta[aria-current="page"], .bn-cta:hover { color: #fff; background: var(--brand-2); }
.more-sheet { border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.more-sheet a, .more-sheet button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 48px; padding: 12px; border: 0; background: none;
  color: var(--ink); text-decoration: none; text-align: left; cursor: pointer; border-radius: 10px;
}
.more-sheet a:hover, .more-sheet button:hover { background: var(--bg); }

@media (min-width: 768px) {
  :root { --header: 64px; }
  h1 { font-size: 1.6rem; }
  .content { padding: 24px 24px 48px; }
  .grid { gap: 16px; }
  .grid.stats { grid-template-columns: repeat(4, 1fr); }
  .grid-2, .mode-cards { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1.1fr .9fr; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: row; justify-content: space-between; align-items: center; }
  .page-head .btn { width: auto; }
  .row-actions > .btn { flex: 0 0 auto; }
  .pdf-frame { height: 56vh; min-height: 280px; }
  .dialog-back { place-items: center; align-items: center; }
  .dialog { width: min(480px, 92vw); border-radius: 16px; padding: 24px; }
  .pdf-dialog { width: min(960px, 96vw); }
  .input, .select, .textarea { font-size: inherit; }
  .drop { padding: 36px; }
  .table { min-width: 0; }
}

@media (min-width: 1024px) {
  .app {
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    padding-bottom: 0;
  }
  .sidebar {
    display: flex; flex-direction: column; gap: 8px;
    background: var(--brand); color: #e8f2f2; padding: 22px 16px;
  }
  .bottom-nav, .search-btn, .header-brand { display: none; }
  .search { display: block; }
  .header { padding: 0 24px; }
  .content { padding: 28px 28px 64px; }
  .wizard-actions { position: static; background: none; padding: 16px 0 0; }
  .wizard-actions .btn { flex: none; }
  .toast { left: auto; right: 20px; bottom: 20px; max-width: 360px; }
}
