/* Fontes hospedadas localmente (sem requisicoes a terceiros) */
@font-face { font-family: "Newsreader"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/newsreader-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/newsreader-latin-400-italic.woff2) format("woff2"); }
@font-face { font-family: "Newsreader"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/newsreader-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); }

:root {
  --paper: #edf1f3;
  --surface: #fbfcfd;
  --ink: #12212f;
  --muted: #566877;
  --rule: #c9d4db;
  --action: #1b3a57;
  --action-ink: #ffffff;
  --focus: #2f6fb5;
  --seal: #0b7a5a;
  --seal-tint: #dcf0e8;
  --alarm: #b8321b;
  --alarm-tint: #f8e2dd;
  --hero: #12212f;
  --hero-ink: #e8eff4;
  --hero-muted: #8da1b1;
  --node-seed: #1b3a57;
  --node-near: #8a9bab;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1923;
    --surface: #14232f;
    --ink: #e6eef3;
    --muted: #93a6b5;
    --rule: #2a3c4a;
    --action: #9fcdf5;
    --action-ink: #0d1923;
    --focus: #7fb4ea;
    --seal: #4fd1a5;
    --seal-tint: #12352b;
    --alarm: #ff9079;
    --alarm-tint: #3b1c16;
    --hero: #091219;
    --node-seed: #9fcdf5;
    --node-near: #5d7284;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.55 var(--sans);
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--action); }
h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); }
h2 { font-size: 1.35rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.lede { color: var(--muted); max-width: 62ch; margin-top: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 28px; padding: 0 clamp(16px, 4vw, 40px);
  background: var(--surface); border-bottom: 1px solid var(--rule); min-height: 60px; flex-wrap: wrap;
}
.wordmark { font-family: var(--serif); font-weight: 600; font-size: 1.2rem; margin-right: auto; padding: 14px 0; }
.topbar nav { display: flex; gap: 4px; align-self: stretch; }
.topbar nav a {
  display: flex; align-items: center; padding: 0 14px; color: var(--muted); text-decoration: none; font-weight: 500;
  border-bottom: 3px solid transparent; margin-bottom: -1px; min-height: 44px;
}
.topbar nav a:hover { color: var(--ink); }
.topbar nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.whoami { display: flex; align-items: center; gap: 14px; padding: 8px 0; color: var(--muted); font-size: .92rem; }
.whoami form { margin: 0; }

main { max-width: 1120px; margin: 0 auto; padding: clamp(24px, 5vw, 48px) clamp(16px, 4vw, 40px) 64px; }
.page-head { margin-bottom: 28px; }
.stack > * + * { margin-top: 28px; }

/* ---------- formularios ---------- */
label, .label { display: block; margin: 0 0 6px; font-weight: 500; font-size: .92rem; }
input[type=text], input[type=password], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--muted); border-radius: 6px;
}
textarea { min-height: 112px; resize: vertical; font-family: var(--serif); font-size: 1.15rem; line-height: 1.45; padding: 14px; }
.btn, button {
  font: inherit; font-weight: 600; min-height: 44px; padding: 10px 22px; border: 0; border-radius: 6px;
  background: var(--action); color: var(--action-ink); cursor: pointer;
}
.btn:hover, button:hover:not(:disabled):not(.quiet) { filter: brightness(1.12); }
button:disabled { opacity: .6; cursor: progress; }
button.quiet {
  background: none; color: var(--muted); font-weight: 500; padding: 10px 6px; text-decoration: underline; text-underline-offset: 3px;
}
button.quiet:hover { color: var(--ink); }
button.ghost { background: transparent; color: var(--action); border: 1px solid var(--rule); padding: 6px 12px; min-height: 36px; font-weight: 500; }
.field-row { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.field-row > .grow { flex: 1 1 260px; }

/* ---------- avisos e selos ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 6px; border: 1px solid; }
.notice.ok { background: var(--seal-tint); color: var(--seal); border-color: var(--seal); }
.notice.bad { background: var(--alarm-tint); color: var(--alarm); border-color: var(--alarm); }
.notice svg { flex: none; margin-top: 2px; }
.notice + .notice { margin-top: 8px; }
.seal-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.seal-badge.ok { color: var(--seal); }
.seal-badge.bad { color: var(--alarm); }

/* ---------- login ---------- */
.login-page { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); min-height: 100vh; }
.login-hero {
  background: var(--hero); color: var(--hero-ink); padding: clamp(32px, 6vw, 72px);
  display: flex; flex-direction: column; justify-content: space-between; gap: 48px;
}
.login-hero .wordmark { margin: 0; padding: 0; color: var(--hero-ink); }
.login-hero h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); max-width: 17ch; font-weight: 400; }
.proof { border-top: 1px solid #2a3c4a; padding-top: 20px; max-width: 520px; }
.proof .file { color: var(--hero-muted); font-size: .92rem; margin-bottom: 8px; }
.proof .hash { font: 400 .95rem/1.5 var(--mono); word-break: break-all; color: var(--hero-ink); min-height: 3em; }
.proof .verdict { display: flex; align-items: center; gap: 12px; margin-top: 16px; color: #4fd1a5; font-weight: 600; }
.proof .verdict svg circle { stroke-dasharray: 63; stroke-dashoffset: 63; }
.proof .verdict svg path { stroke-dasharray: 20; stroke-dashoffset: 20; }
.proof.done .verdict svg circle { animation: draw .5s ease-out forwards; }
.proof.done .verdict svg path { animation: draw .35s .4s ease-out forwards; }
.proof .verdict span { opacity: 0; }
.proof.done .verdict span { opacity: 1; transition: opacity .4s .5s; }
.proof .note { color: var(--hero-muted); font-size: .85rem; margin-top: 10px; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px clamp(16px, 5vw, 64px); }
.login-form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 1.8rem; margin-bottom: 20px; }
.login-form .notice { margin-bottom: 18px; }
.login-form .field + .field { margin-top: 16px; }
.login-form button { width: 100%; margin-top: 24px; }

/* ---------- upload ---------- */
.dropzone {
  display: block; border: 2px dashed var(--muted); border-radius: 10px; padding: 36px 24px; text-align: center; cursor: pointer;
  background: var(--surface); margin: 0;
}
.dropzone:hover, .dropzone.over { border-color: var(--action); background: var(--paper); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone .title { font-family: var(--serif); font-size: 1.35rem; display: block; }
.dropzone .hint { color: var(--muted); font-weight: 400; display: block; margin-top: 4px; }
.dropzone.has-file { border-style: solid; border-color: var(--seal); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-form .field-row { margin-top: 20px; }
.receipt {
  border: 1px solid var(--seal); border-left-width: 6px; background: var(--surface); padding: 20px 22px; border-radius: 4px 10px 10px 4px;
}
.receipt h2 { color: var(--seal); display: flex; align-items: center; gap: 10px; }
.receipt dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 14px 0 0; }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; word-break: break-all; }
.receipt.bad { border-color: var(--alarm); }
.receipt.bad h2 { color: var(--alarm); }
.mono { font-family: var(--mono); font-size: .85rem; }
.doc-list-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; font-size: .88rem; }
td.name { font-weight: 500; word-break: break-word; }
.hash-cell { display: flex; align-items: center; gap: 8px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- consulta ---------- */
.ask-form { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 20px; }
.ask-form .field-row { margin-top: 14px; }
.ask-form .model { flex: 0 1 300px; }
.verdict-strip { margin-bottom: 20px; }
.answer-block { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: clamp(20px, 3vw, 32px); }
.answer-text { font-family: var(--serif); font-size: 1.3rem; line-height: 1.6; max-width: 66ch; white-space: pre-wrap; }
.cite {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.5em; height: 1.5em; padding: 0 .3em; margin: 0 .1em;
  font: 600 .72em/1 var(--sans); color: var(--action); background: transparent; border: 1px solid var(--action); border-radius: 4px;
  vertical-align: .25em; text-decoration: none; min-height: 0; cursor: pointer;
}
.cite:hover { background: var(--action); color: var(--action-ink); filter: none; }
.evidence { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; margin-top: 28px; align-items: start; }
.evidence h2 { margin-bottom: 12px; }
#graph { height: 440px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); }
.legend { display: flex; gap: 20px; margin-top: 10px; color: var(--muted); font-size: .88rem; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.source { padding: 14px 0 14px 16px; border-left: 3px solid var(--rule); scroll-margin-top: 16px; }
.source + .source { margin-top: 4px; }
.source.flash { border-left-color: var(--action); background: var(--surface); }
.source header { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.source .num { font-weight: 600; color: var(--action); }
.source .file { font-weight: 500; word-break: break-word; }
.source .score { color: var(--muted); font-size: .85rem; margin-left: auto; }
.source p { color: var(--ink); font-size: .95rem; max-width: 70ch; }
.progress-note { color: var(--muted); padding: 24px 0; }

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; min-height: 0; }
  .login-hero { gap: 28px; padding: 28px 20px; }
  .login-hero h1 { font-size: 1.8rem; }
  .evidence { grid-template-columns: 1fr; }
  .receipt dl { grid-template-columns: 1fr; gap: 0; }
  .receipt dd { margin-bottom: 8px; }
  .topbar { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .proof .verdict svg circle, .proof .verdict svg path { stroke-dashoffset: 0; }
  .proof .verdict span { opacity: 1; }
}

/* ---------- usuarios ---------- */
dialog { border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 24px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 20, 30, .55); }
.dlg-actions { display: flex; gap: 12px; align-items: center; margin-top: 22px; flex-wrap: wrap; }
button.danger { background: var(--alarm); color: #fff; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions button { min-height: 36px; padding: 6px 12px; }
td select { min-height: 36px; padding: 4px 8px; width: auto; }
.you { color: var(--muted); font-weight: 400; margin-left: 8px; }
