/* Garante que o atributo [hidden] sempre esconda o elemento, mesmo quando
   uma classe abaixo (ex.: .login-shell, com display:flex) empataria em
   especificidade com a regra padrão do navegador para [hidden]. */
[hidden]{ display:none !important; }

:root{
  --bg:#F5F7F8; --surface:#FFFFFF; --surface-2:#ECF0F2; --border:#DCE2E6;
  --ink:#101820; --ink-muted:#5C6670;
  --accent:#0F7C89; --accent-ink:#FFFFFF; --accent-soft:#E3F1F2;
  --success:#1E8E5A; --success-soft:#E4F5EC;
  --danger:#C13F2C; --danger-soft:#FBE7E3;
  --warning:#B4780F; --warning-soft:#FBF0DE;
  --shadow:0 1px 2px rgba(16,24,32,.06), 0 1px 12px rgba(16,24,32,.04);
  color-scheme:light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0C1116; --surface:#131A21; --surface-2:#1B242D; --border:#26313B;
    --ink:#E7ECF0; --ink-muted:#98A5B0;
    --accent:#35B7C4; --accent-ink:#06232A; --accent-soft:#163038;
    --success:#34C77E; --success-soft:#12301F;
    --danger:#E5695A; --danger-soft:#331815;
    --warning:#E0A83F; --warning-soft:#332208;
    --shadow:0 1px 2px rgba(0,0,0,.4), 0 1px 12px rgba(0,0,0,.3);
    color-scheme:dark;
  }
}
*{box-sizing:border-box;}
html,body{ height:100%; }
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.mono, input[type="number"]{ font-family:"IBM Plex Mono","SFMono-Regular",Consolas,monospace; font-variant-numeric:tabular-nums; }
h1,h2,h3{ margin:0; }
p{ margin:0; }
a{ color:var(--accent); }
button{ font-family:inherit; }

/* ---------- login ---------- */
.login-shell{
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;
}
.login-card{
  background:var(--surface); border:1px solid var(--border); border-radius:16px;
  box-shadow:var(--shadow); padding:36px 32px; width:100%; max-width:380px;
  display:flex; flex-direction:column; align-items:center; gap:18px;
}
.login-logo{ height:60px; width:auto; max-width:240px; object-fit:contain; border-radius:0; }
.login-logo-fallback{
  width:64px; height:64px; border-radius:14px; background:var(--accent-soft); color:var(--accent);
  display:flex; align-items:center; justify-content:center; font-weight:700; font-size:22px;
}
.login-title{ text-align:center; }
.login-title h1{ font-size:17px; font-weight:700; }
.login-title span{ display:block; font-size:12.5px; color:var(--ink-muted); margin-top:3px; }
.login-form{ width:100%; display:flex; flex-direction:column; gap:12px; }
.login-error{ font-size:12.5px; color:var(--danger); text-align:center; min-height:16px; }

/* ---------- app shell (mesma linguagem visual do protótipo original) ---------- */
.shell{ max-width:1120px; margin:0 auto; padding:20px 20px 60px; }
.topbar{
  position:sticky; top:0; z-index:20; background:var(--bg);
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:14px 0 10px; flex-wrap:wrap; border-bottom:1px solid var(--border);
}
.brand{ display:flex; align-items:center; gap:10px; }
.brand-mark{ height:30px; width:auto; max-width:150px; object-fit:contain; border-radius:0; flex:none; }
.brand-mark-fallback{
  width:34px; height:34px; border-radius:9px;
  background:linear-gradient(155deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--ink)));
  display:flex; align-items:center; justify-content:center; color:var(--accent-ink); font-weight:700; font-size:14px; flex:none;
}
.brand-text h1{ font-size:16px; font-weight:700; letter-spacing:-.01em; }
.brand-text span{ display:block; font-size:11.5px; color:var(--ink-muted); margin-top:1px; }

.user-chip{
  display:flex; align-items:center; gap:8px; font-size:12.5px; color:var(--ink-muted);
  background:var(--surface); border:1px solid var(--border); border-radius:999px; padding:5px 12px 5px 6px;
}
.user-dot{ width:20px; height:20px; border-radius:999px; background:var(--accent-soft); color:var(--accent); display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:700; flex:none; }
.user-chip b{ color:var(--ink); font-weight:600; }

.tabs{ display:flex; gap:2px; overflow-x:auto; padding-top:10px; border-bottom:1px solid var(--border); margin-bottom:22px; }
.tab-btn{
  appearance:none; border:none; background:transparent; cursor:pointer; padding:9px 14px; font-size:13.5px; font-weight:600;
  color:var(--ink-muted); border-radius:8px 8px 0 0; white-space:nowrap; border-bottom:2px solid transparent; margin-bottom:-1px;
}
.tab-btn:hover{ color:var(--ink); }
.tab-btn.active{ color:var(--accent); border-bottom-color:var(--accent); }

section[data-view]{ display:flex; flex-direction:column; gap:22px; }
section[data-view][hidden]{ display:none; }

.card{ background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:20px; box-shadow:var(--shadow); }
.card-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.card-head h2{ font-size:15.5px; font-weight:700; }
.card-head p{ font-size:12.5px; color:var(--ink-muted); margin-top:3px; max-width:56ch; }

.grid{ display:grid; gap:16px; }
.grid.cols-3{ grid-template-columns:repeat(3,1fr); }
.grid.cols-2{ grid-template-columns:repeat(2,1fr); }
@media (max-width:760px){ .grid.cols-3{ grid-template-columns:1fr 1fr; } .grid.cols-2{ grid-template-columns:1fr; } }
@media (max-width:520px){ .grid.cols-3{ grid-template-columns:1fr; } }

label{ display:block; font-size:12px; font-weight:600; color:var(--ink-muted); margin-bottom:5px; }
.field{ display:flex; flex-direction:column; }
input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="search"], select, textarea{
  width:100%; border:1px solid var(--border); background:var(--bg); color:var(--ink);
  border-radius:9px; padding:9px 11px; font-size:13.5px; font-family:inherit;
}
input:focus, select:focus, textarea:focus{ outline:2px solid var(--accent); outline-offset:1px; }
textarea{ resize:vertical; min-height:64px; }

.btn{
  appearance:none; border:1px solid var(--border); background:var(--surface); color:var(--ink);
  padding:9px 15px; border-radius:9px; font-size:13px; font-weight:600; cursor:pointer;
  display:inline-flex; align-items:center; gap:7px;
}
.btn:hover{ filter:brightness(0.97); }
@media (prefers-color-scheme:dark){ :root:not([data-theme="light"]) .btn:hover{ filter:brightness(1.15); } }
.btn:active{ transform:translateY(1px); }
.btn:disabled{ opacity:.5; cursor:not-allowed; }
.btn.primary{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); width:100%; justify-content:center; }
.btn.ghost{ background:transparent; border-color:transparent; padding-inline:8px; }
.btn.sm{ padding:6px 11px; font-size:12px; }
.btn-row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }

table{ width:100%; border-collapse:collapse; font-size:13px; }
th{ text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--ink-muted); font-weight:700; padding:8px 10px; border-bottom:1px solid var(--border); }
td{ padding:10px; border-bottom:1px solid var(--border); vertical-align:top; }
tr:last-child td{ border-bottom:none; }
.table-wrap{ overflow-x:auto; }
.muted{ color:var(--ink-muted); }
.empty{ padding:22px 10px; text-align:center; color:var(--ink-muted); font-size:13px; }
.empty b{ display:block; color:var(--ink); font-size:14px; margin-bottom:4px; }

.pill{ display:inline-flex; align-items:center; gap:5px; font-size:11.5px; font-weight:600; padding:3px 9px; border-radius:999px; white-space:nowrap; }
.pill.ok{ background:var(--success-soft); color:var(--success); }
.pill.bad{ background:var(--danger-soft); color:var(--danger); }
.pill.warn{ background:var(--warning-soft); color:var(--warning); }
.pill.idle{ background:var(--surface-2); color:var(--ink-muted); }
.dot{ width:6px; height:6px; border-radius:999px; background:currentColor; }

.point-row{ display:grid; grid-template-columns:1.3fr .8fr 1fr 1fr .8fr auto; gap:8px; align-items:end; padding:10px 0; border-bottom:1px dashed var(--border); }
.point-row:last-of-type{ border-bottom:none; }
@media (max-width:760px){ .point-row{ grid-template-columns:1fr 1fr; } }

.notice{ border:1px solid var(--border); background:var(--surface-2); border-radius:11px; padding:12px 14px; font-size:12.5px; color:var(--ink-muted); display:flex; gap:10px; align-items:flex-start; }
.notice.warn{ background:var(--warning-soft); border-color:transparent; color:var(--warning); }
.notice.bad{ background:var(--danger-soft); border-color:transparent; color:var(--danger); }
.notice.ok{ background:var(--success-soft); border-color:transparent; color:var(--success); }

.analysis-item{ border:1px solid var(--border); border-radius:12px; padding:14px; display:flex; flex-direction:column; gap:10px; }
.analysis-item + .analysis-item{ margin-top:10px; }
.analysis-top{ display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; align-items:center; }
.analysis-top h4{ font-size:13.5px; font-weight:700; }
.analysis-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:10px; font-size:12.5px; }
@media (max-width:700px){ .analysis-grid{ grid-template-columns:1fr 1fr; } }
.analysis-grid div span{ display:block; color:var(--ink-muted); font-size:10.5px; text-transform:uppercase; letter-spacing:.03em; margin-bottom:2px; }
.analysis-reason{ font-size:12px; color:var(--ink-muted); background:var(--surface-2); border-radius:8px; padding:8px 10px; }
.norma-link{ font-size:11.5px; color:var(--accent); }

.cert-doc{ background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:32px; box-shadow:var(--shadow); }
.cert-doc-head{ text-align:center; border-bottom:2px solid var(--ink); padding-bottom:16px; margin-bottom:18px; }
.cert-doc-head img{ width:52px; height:52px; object-fit:cover; border-radius:10px; margin-bottom:8px; }
.cert-doc-head h2{ font-size:19px; letter-spacing:.02em; }
.cert-doc-head .lab{ font-size:13px; color:var(--ink-muted); margin-top:4px; }
.cert-number{ font-size:12.5px; color:var(--ink-muted); margin-top:8px; }
.cert-grid{ display:grid; grid-template-columns:1fr 1fr; gap:6px 26px; font-size:13px; margin-bottom:18px; }
@media (max-width:620px){ .cert-grid{ grid-template-columns:1fr; } }
.cert-grid div{ display:flex; justify-content:space-between; border-bottom:1px dotted var(--border); padding-bottom:4px; gap:10px; }
.cert-grid span:first-child{ color:var(--ink-muted); }
.cert-verdict{ text-align:center; padding:14px; border-radius:12px; margin-block:18px; font-weight:700; font-size:15px; }
.cert-sign{ margin-top:26px; padding-top:16px; border-top:1px solid var(--border); font-size:12.5px; color:var(--ink-muted); display:flex; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.cert-sign b{ color:var(--ink); display:block; font-size:13px; }


.toast{ position:fixed; left:50%; bottom:22px; transform:translateX(-50%); background:var(--ink); color:var(--bg);
  padding:10px 16px; border-radius:10px; font-size:12.5px; z-index:999; box-shadow:var(--shadow); max-width:88vw; text-align:center; }
.toast.error{ background:var(--danger); }

/* ---------- login: senha com botão mostrar/ocultar ---------- */
.input-with-btn{ display:flex; gap:6px; align-items:center; }
.input-with-btn input{ flex:1; }

/* ---------- chip do usuário: papel ---------- */
.user-chip small{ display:block; font-size:10.5px; line-height:1.1; }
.tab-count{ display:inline-block; min-width:18px; padding:1px 6px; border-radius:999px; background:var(--surface-2); color:var(--ink-muted); font-size:10.5px; margin-left:4px; }

/* ---------- indicador de etapas ---------- */
.steps{ list-style:none; display:grid; grid-template-columns:repeat(4,1fr); gap:6px; margin:0 0 -6px; padding:0; }
.steps li{ display:flex; align-items:center; gap:8px; font-size:12px; font-weight:600; color:var(--ink-muted); padding:8px 10px; border-radius:10px; background:var(--surface); border:1px solid var(--border); }
.steps li span{ width:22px; height:22px; border-radius:999px; background:var(--surface-2); display:inline-flex; align-items:center; justify-content:center; font-size:11px; flex:none; }
.steps li.active{ color:var(--accent); border-color:var(--accent); }
.steps li.active span{ background:var(--accent); color:var(--accent-ink); }
.steps li.done{ color:var(--success); }
.steps li.done span{ background:var(--success-soft); color:var(--success); }
@media (max-width:640px){ .steps{ grid-template-columns:1fr 1fr; } }

/* ---------- área de anexo (arrastar e soltar) ---------- */
.dropzone{ border:2px dashed var(--border); border-radius:12px; padding:22px; text-align:center; cursor:pointer; background:var(--bg); transition:border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over{ border-color:var(--accent); background:var(--accent-soft); outline:none; }
.dropzone-icon{ font-size:26px; margin-bottom:4px; }
.dropzone-idle{ font-size:13.5px; color:var(--ink); }
.dropzone-idle small{ display:block; margin-top:4px; font-size:12px; }
.dropzone-file{ display:flex; align-items:center; gap:12px; text-align:left; }
.dropzone-file .dropzone-icon{ margin:0; }
.dropzone-file > div{ flex:1; min-width:0; }
.dropzone-file b{ display:block; font-size:13.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dropzone-file small{ display:block; font-size:12px; }

/* ---------- pré-análise ---------- */
.analysis-item.zona{ border-color:var(--warning); }
.analysis-item.sem-norma{ border-color:var(--danger); }
.analysis-badges{ display:flex; gap:6px; flex-wrap:wrap; align-items:center; }

/* ---------- certificado (extras) ---------- */
.cert-doc-head .lab + .lab{ margin-top:2px; }
.cert-section-title{ font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-muted); font-weight:700; margin:16px 0 6px; }
.cert-text{ font-size:12.5px; color:var(--ink); white-space:pre-wrap; }
.cert-footnote{ font-size:11px; color:var(--ink-muted); margin-top:18px; border-top:1px dotted var(--border); padding-top:10px; }
.cert-doc td.mono{ white-space:nowrap; }
.cert-doc td .obs{ display:block; font-size:11px; color:var(--ink-muted); margin-top:3px; }

/* ---------- impressão: só o certificado ---------- */
@media print{
  body{ background:#fff; color:#000; }
  .topbar, .tabs, .steps, .no-print, #stepAnexo, #stepFormulario, #stepRevisao, #loginScreen, .toast{ display:none !important; }
  .shell{ max-width:none; padding:0; }
  #stepCertificado{ border:none; box-shadow:none; padding:0; }
  .cert-doc{ border:none; box-shadow:none; padding:0; }
  .pill{ border:1px solid #999; }
}
