/* DocCheck — estilos (sem dependências externas) */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #16202c;
  --text-2: #5b6776;
  --primary: #0f766e;
  --primary-hover: #0c5f58;
  --primary-soft: #e6f4f2;
  --success: #15803d; --success-soft: #e7f6ec;
  --danger: #c2410c; --danger-strong: #b91c1c; --danger-soft: #fdeceb;
  --warning: #a16207; --warning-soft: #fdf5dc;
  --info: #1d4ed8; --info-soft: #e8efff;
  --muted-soft: #eef0f3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1319; --surface: #151c24; --surface-2: #1b242e; --border: #26313d;
    --text: #e6ebf1; --text-2: #97a3b1;
    --primary: #2bb3a6; --primary-hover: #3cc4b7; --primary-soft: #12302d;
    --success: #4ade80; --success-soft: #11291b;
    --danger: #fb923c; --danger-strong: #f87171; --danger-soft: #331a14;
    --warning: #facc15; --warning-soft: #2e2710;
    --info: #93b4ff; --info-soft: #15203a;
    --muted-soft: #1f2832;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .25rem; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2, .h2 { font-size: 1.15rem; font-weight: 650; }
.h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .5rem; }
a { color: var(--primary); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; word-break: break-all; }
small, .small { font-size: .85rem; }
.muted { color: var(--text-2); }
.text-danger { color: var(--danger-strong) !important; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.sr-only, .visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.link { color: var(--primary); text-decoration: none; font-weight: 550; }
.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout do painel ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: .25rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 750; font-size: 1.15rem; color: var(--text); text-decoration: none; padding: 0 .5rem; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; font-size: .95rem; }
.company-name { color: var(--text-2); font-size: .85rem; padding: 0 .5rem; margin: .1rem 0 1rem; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 1rem .6rem .3rem; }
.nav-link { display: block; padding: .5rem .65rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.sidebar-user { border-top: 1px solid var(--border); padding-top: .9rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sidebar-user strong { display: block; font-size: .9rem; }
.sidebar-user span { font-size: .8rem; color: var(--text-2); }
.main { padding: 1.75rem 2rem 3rem; max-width: 1360px; width: 100%; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.back-link { display: inline-block; color: var(--text-2); text-decoration: none; font-size: .88rem; margin-bottom: .35rem; }
.back-link:hover { color: var(--primary); }
.actions, .btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card.flush { padding: 0; overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.card-header.pad { padding: 1rem 1.25rem .25rem; }
.card-title { font-size: 1rem; font-weight: 650; margin-bottom: .75rem; }
.stack > .card { margin-bottom: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.grid-doc { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 1.25rem; }
.form .grid-2, .form .grid-3 { gap: 1rem; }
.narrow { max-width: 420px; margin: 0 auto; }
.narrow-form { max-width: 720px; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-2); }

/* ---------- Estatísticas ---------- */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .35rem; border-top: 3px solid var(--primary); }
a.stat:hover { border-color: var(--primary); }
.stat-danger { border-top-color: var(--danger); }
.stat-warning { border-top-color: var(--warning); }
.stat-success { border-top-color: var(--success); }
.stat-label { font-size: .82rem; color: var(--text-2); }
.stat-value { font-size: 1.75rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.big-number { font-size: 2.4rem; font-weight: 750; margin: 0; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 650; background: var(--surface-2); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table.compact th, .table.compact td { padding: .45rem .6rem; }
.table td.reason { max-width: 280px; }
tr.muted td { color: var(--text-2); }
.progress-mini { width: 56px; height: 6px; vertical-align: middle; margin-right: .35rem; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; padding: .9rem; border-top: 1px solid var(--border); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 650; white-space: nowrap; line-height: 1.5; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger-strong); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--muted-soft); color: var(--text); }
.badge-muted { background: var(--muted-soft); color: var(--text-2); }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; line-height: 1.2; background: none; color: var(--text); transition: background .15s, border-color .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--text-2); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger-strong); color: #fff; }
.btn-danger-ghost { color: var(--danger-strong); border-color: color-mix(in srgb, var(--danger-strong) 35%, transparent); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-lg { padding: .85rem 1.2rem; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn.is-disabled { opacity: .5; pointer-events: none; }
@media (prefers-color-scheme: dark) { .btn-primary, .btn-success, .btn-danger { color: #0e1319; } }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field legend { font-size: .85rem; font-weight: 600; color: var(--text); }
.field.grow { flex: 1; min-width: 220px; }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-sm { width: 80px !important; padding: .35rem .5rem !important; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.check-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.field-error { color: var(--danger-strong); font-size: .83rem; margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.filters { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; padding: 1rem 1.25rem; }
.filters .field { min-width: 150px; }
.filters-actions { display: flex; gap: .5rem; }

/* ---------- Alertas ---------- */
.alert { border-radius: var(--radius-sm); padding: .8rem 1rem; margin-bottom: 1rem; font-size: .92rem; border: 1px solid transparent; }
.alert ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--danger-strong); border-color: color-mix(in srgb, var(--danger-strong) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }

/* ---------- Detalhes ---------- */
.dl { display: grid; grid-template-columns: 110px 1fr; gap: .4rem .75rem; margin: 0; font-size: .92rem; }
.dl dt { color: var(--text-2); }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.link-box summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .9rem; margin-bottom: .5rem; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { font-family: var(--mono); font-size: .8rem; }
.inline-form { position: relative; }
.inline-form > summary { list-style: none; }
.inline-form > summary::-webkit-details-marker { display: none; }
.popover { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: 0 10px 30px rgba(0,0,0,.15); display: flex; flex-direction: column; gap: .6rem; }
.danger-zone summary { cursor: pointer; color: var(--danger-strong); font-weight: 600; }
.danger-zone .form { margin-top: 1rem; max-width: 480px; }
.plain-list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .4rem; }
.help summary { cursor: pointer; color: var(--text-2); font-size: .88rem; }
.help ul { font-size: .85rem; color: var(--text-2); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; max-height: 520px; overflow-y: auto; }
.timeline li { display: grid; grid-template-columns: 18px 1fr; gap: .6rem; padding-bottom: .9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline p { margin: 0; font-size: .9rem; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--text-2); margin-top: 3px; }
.tl-document-approved .tl-dot, .tl-process-completed .tl-dot { border-color: var(--success); }
.tl-document-rejected .tl-dot, .tl-analysis-failed .tl-dot, .tl-whatsapp-failed .tl-dot, .tl-process-cancelled .tl-dot { border-color: var(--danger-strong); }
.tl-document-manual-review .tl-dot { border-color: var(--warning); }
.tl-whatsapp-sent .tl-dot, .tl-client-notified .tl-dot { border-color: var(--primary); }

/* Documento */
.preview { padding: .5rem; display: flex; align-items: center; justify-content: center; min-height: 480px; background: var(--surface-2); }
.preview-frame { width: 100%; height: 72vh; border: 0; border-radius: var(--radius-sm); background: #fff; }
.preview-img { max-width: 100%; max-height: 72vh; object-fit: contain; border-radius: var(--radius-sm); }
.decision { display: grid; gap: 1rem; margin-bottom: .75rem; }
.analysis { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .9rem; margin-bottom: .6rem; }
.analysis summary { cursor: pointer; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.analysis > p, .analysis > table { margin-top: .6rem; }

/* Revisão */
.review-list { display: flex; flex-direction: column; gap: .75rem; }
.review-item { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin: 0; }
.review-item p { margin: .15rem 0; }
.review-actions { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }
.review-actions form { margin: 0; }

/* ---------- Páginas simples (login/erro) ---------- */
.minimal-main { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.minimal .card { width: 100%; max-width: 420px; padding: 2rem; }
.login-brand { display: flex; align-items: center; gap: .55rem; font-weight: 750; font-size: 1.2rem; margin-bottom: 1.25rem; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); margin: 0; }

/* ---------- Área do cliente (mobile-first) ---------- */
body.client { background: var(--bg); }
.client-header { background: var(--primary); color: #fff; padding: 1.75rem 1.25rem 1.5rem; }
@media (prefers-color-scheme: dark) { .client-header { background: #0f3f3b; } }
.client-header h1 { font-size: 1.55rem; color: #fff; }
.client-header p { opacity: .92; margin: 0; }
.client-company { font-size: .8rem !important; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; opacity: .8 !important; margin-bottom: .6rem !important; }
.client-progress { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; font-size: .85rem; }
.client-progress progress { flex: 1; height: 8px; }
.client-main { max-width: 560px; margin: 0 auto; padding: .25rem 1rem 2rem; }
.client-section { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 1.5rem .25rem .6rem; }
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; }
.doc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1rem; box-shadow: var(--shadow); border-left: 4px solid var(--border); }
.doc-card.tone-danger { border-left-color: var(--danger-strong); }
.doc-card.tone-success { border-left-color: var(--success); }
.doc-card.tone-warning { border-left-color: var(--warning); }
.doc-card.tone-neutral { border-left-color: var(--primary); }
.doc-head { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.doc-head h3 { font-size: 1.02rem; margin: 0; }
.doc-desc { font-size: .85rem; color: var(--text-2); margin: .25rem 0 0; }
.doc-reason { background: var(--danger-soft); color: var(--danger-strong); border-radius: 10px; padding: .6rem .75rem; font-size: .88rem; margin: .75rem 0 0; }
.doc-error { background: var(--danger-soft); color: var(--danger-strong); border-radius: 10px; padding: .6rem .75rem; font-size: .88rem; margin: .75rem 0 0; font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 700; padding: .25rem .6rem; border-radius: 999px; white-space: nowrap; }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-danger { background: var(--danger-soft); color: var(--danger-strong); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-neutral { background: var(--primary-soft); color: var(--primary); }
.upload-form { margin-top: .9rem; display: flex; flex-direction: column; gap: .55rem; }
.upload-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.upload-buttons .btn { width: 100%; cursor: pointer; padding: .85rem .6rem; font-size: .95rem; white-space: nowrap; }
.upload-buttons .btn:only-child { grid-column: 1 / -1; }
.upload-hint { font-size: .78rem; color: var(--text-2); text-align: center; margin: 0; }
.upload-selected { display: flex; flex-direction: column; gap: .5rem; }
.upload-selected [data-filename] { font-size: .85rem; color: var(--text-2); word-break: break-all; text-align: center; }
.upload-progress { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--text-2); text-align: center; }
.upload-progress progress { width: 100%; height: 8px; }
.client-done { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.75rem 1rem; text-align: center; box-shadow: var(--shadow); margin-bottom: 1rem; }
.done-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; margin: 0 auto .75rem; }
.client-tips ul { margin: 0; padding: 1rem 1rem 1rem 2.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; font-size: .9rem; color: var(--text-2); }
.client-footer { text-align: center; font-size: .78rem; color: var(--text-2); padding: 1rem 1rem 2rem; }
.client-footer p { margin: .15rem 0; }
.client .alert { border-radius: 12px; }
progress { accent-color: var(--primary); }

/* ---------- Responsivo ---------- */
@media (max-width: 1200px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-section { display: none; }
  .main { padding: 1.25rem 1rem 2rem; }
  .grid-2, .grid-3, .grid-doc { grid-template-columns: 1fr; }
  .review-item { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .popover { width: 260px; } }

/* ---------- Instalador ---------- */
.install { width: 100%; max-width: 640px; margin: 2rem auto; padding: 0 1rem; }
.install .card { max-width: none; padding: 1.75rem; }
.install-steps { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--text-2); }
.install-steps li { display: flex; align-items: center; gap: .35rem; }
.install-steps li span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--muted-soft); font-weight: 700; font-size: .75rem; }
.install-steps li.is-current { color: var(--text); font-weight: 650; }
.install-steps li.is-current span { background: var(--primary); color: #fff; }
.install-steps li.is-done span { background: var(--success-soft); color: var(--success); }
.install-howto { padding-left: 1.2rem; }
.install-howto li { margin-bottom: .35rem; }
.req-list { list-style: none; padding: 0; margin: .75rem 0; display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.req-list li { display: flex; gap: .6rem; align-items: flex-start; }
.req-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: .7rem; font-weight: 800; flex: none; margin-top: 1px; }
.req-list .ok .req-icon { background: var(--success-soft); color: var(--success); }
.req-list .fail .req-icon { background: var(--danger-soft); color: var(--danger-strong); }
.req-list .warn .req-icon { background: var(--warning-soft); color: var(--warning); }
.env-box { width: 100%; font-family: var(--mono); font-size: .8rem; margin: .5rem 0 1rem; }
