/* Explorador de SAF-T (PT). Fonts are kept with the site (SIL Open Font License, see the
   OFL files next to them); nothing is loaded from other domains. */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/cormorant-garamond-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); }

:root {
  --bg: #F4EFE3; --surface: #FFFCF5; --surface-2: #F9F4E8; --ink: #0B1220; --muted: #4B5468; --line: #DCD3BF;
  --gold: #85560A; --gold-mark: #C28A2B; --btn: #0B1220; --btn-ink: #F4EFE3;
  --ok: #2B6A3C; --info: #2F5E8F; --warn: #8A5400; --err: #A1271B;
  --bar: #A86F12; --grid: #E6DECB; --head: #EFE7D6; --focus: #C28A2B; --drop: #FBF6EA;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1220; --surface: #121B2E; --surface-2: #17213A; --ink: #EEE8DB; --muted: #AAB3C5; --line: #2A3754;
    --gold: #E8B04B; --gold-mark: #E8B04B; --btn: #E8B04B; --btn-ink: #0B1220;
    --ok: #7FC896; --info: #8DB8EE; --warn: #F0BE5E; --err: #F29489;
    --bar: #B8842A; --grid: #24304A; --head: #1A2540; --focus: #E8B04B; --drop: #141E33;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1220; --surface: #121B2E; --surface-2: #17213A; --ink: #EEE8DB; --muted: #AAB3C5; --line: #2A3754;
  --gold: #E8B04B; --gold-mark: #E8B04B; --btn: #E8B04B; --btn-ink: #0B1220;
  --ok: #7FC896; --info: #8DB8EE; --warn: #F0BE5E; --err: #F29489;
  --bar: #B8842A; --grid: #24304A; --head: #1A2540; --focus: #E8B04B; --drop: #141E33;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.55 "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-wrap: break-word;
}
h1, h2 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; line-height: 1.1; letter-spacing: 0; }
h3, h4 { line-height: 1.25; }
a { color: var(--gold); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.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; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--btn); color: var(--btn-ink); padding: 10px 14px; border-radius: 8px; z-index: 10; text-decoration: none; font-weight: 600; }
.skip:focus { top: 12px; }
.mono, code { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-size: .86rem; }

/* header */
.top { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 6px; flex-wrap: wrap; }
.brand { margin: 0; display: inline-flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: url("../img/qpc-mark.svg") center / cover no-repeat; flex: none; }
.toolbar { display: flex; gap: 8px; align-items: center; }
.intro { padding-top: 18px; padding-bottom: 26px; }
.intro h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); margin: 0 0 12px; }
.lead { font-size: 1.08rem; max-width: 72ch; margin: 0 0 12px; }
.notice { display: block; width: fit-content; max-width: 100%; margin: 8px 0 0; padding: 6px 12px; border: 1px dashed var(--gold-mark); border-radius: 12px; color: var(--muted); font-size: .92rem; }
.notice.privacy { color: var(--ink); border-style: solid; }

/* controls */
button, select, input { font: inherit; color: inherit; }
select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-align: center; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); padding: 8px 24px; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .6; cursor: progress; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }

/* opening a file */
main { padding: 26px 0 56px; }
main:focus { outline: none; }
.open { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px 28px; align-items: start; }
.open > h2 { grid-column: 1 / -1; font-size: clamp(1.8rem, 3.4vw, 2.4rem); margin: 0; }
.drop { border: 2px dashed var(--gold-mark); border-radius: var(--radius); background: var(--drop); padding: 26px 20px; text-align: center; display: grid; justify-items: center; gap: 4px; }
.drop.over { background: var(--surface-2); border-style: solid; }
.drop-text { margin: 0; font-weight: 650; font-size: 1.08rem; }
.drop-or { margin: 0; color: var(--muted); }
.drop { position: relative; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input:focus-visible + .file-btn { outline: 3px solid var(--focus); outline-offset: 3px; }
.examples h3 { margin: 0 0 10px; font-size: 1.05rem; }
.example-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.example-list li { display: grid; gap: 2px; }
.example { justify-content: flex-start; text-align: left; width: fit-content; max-width: 100%; }
.progress, .status, .error { grid-column: 1 / -1; }
.progress { display: grid; gap: 6px; }
.progress-label { font-weight: 600; }
progress { width: 100%; height: 14px; accent-color: var(--bar); }
.status { margin: 0; min-height: 1.5em; color: var(--muted); }
.error { border: 1px solid var(--err); border-left-width: 5px; border-radius: var(--radius); background: var(--surface); padding: 12px 16px; }
.error h3 { margin: 0 0 4px; color: var(--err); font-size: 1rem; }
.error p { margin: 0; }

/* results */
.results { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--line); }
.results:focus { outline: none; }
.res-head { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; justify-content: space-between; }
.res-head h2 { font-size: clamp(1.9rem, 3.8vw, 2.8rem); margin: 0 0 6px; }
.res-meta { margin: 0; color: var(--muted); }
.res-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.kpis { list-style: none; padding: 0; margin: 22px 0 8px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.kpi-label { margin: 0; color: var(--muted); font-size: .9rem; }
.kpi-value { margin: 2px 0 0; font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-note { margin: 2px 0 0; color: var(--muted); font-size: .84rem; }
.kpi a { color: inherit; }
.sums-note, .other-note { margin: 6px 0 0; color: var(--muted); font-size: .9rem; max-width: 90ch; }
.res-nav { margin: 18px 0 0; }
.res-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.res-nav a { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 600; font-size: .92rem; }
.res-nav a:hover { border-color: var(--muted); }
.block { margin-top: 34px; scroll-margin-top: 12px; }
.block > h3 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; font-size: clamp(1.6rem, 3vw, 2.1rem); margin: 0 0 6px; }
.block > h4 { margin: 22px 0 8px; font-size: 1.05rem; }
.block-intro { margin: 0 0 12px; color: var(--muted); max-width: 90ch; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: var(--head); font-weight: 650; white-space: nowrap; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tfoot td, tfoot th { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 700; }
.num { text-align: right; white-space: nowrap; }
.neg { color: var(--err); }
.nowrap { white-space: nowrap; }
.region-row th { background: var(--surface-2); font-weight: 700; }
.share-bar { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: var(--bar); vertical-align: middle; margin-right: 8px; }

/* chart */
.chart { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 4px; margin-bottom: 14px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text, .chart .ticks text { fill: var(--muted); font-size: 12px; font-family: "Hanken Grotesk", system-ui, sans-serif; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.on { filter: brightness(1.15); }
.chart .peak { fill: var(--ink); font-size: 12px; font-weight: 650; font-family: "Hanken Grotesk", system-ui, sans-serif; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: .86rem; line-height: 1.35; white-space: nowrap; transform: translate(-50%, -100%); }
.tip[hidden] { display: none; }

/* checks */
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.check { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--c, var(--muted)); border-radius: var(--radius); padding: 12px 16px; }
.check.lv-ok { --c: var(--ok); } .check.lv-info { --c: var(--info); } .check.lv-warning { --c: var(--warn); } .check.lv-error { --c: var(--err); }
.check-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.check-top h4 { margin: 0; font-size: 1.05rem; }
.level { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c); border: 1px solid currentColor; border-radius: 999px; padding: 0 9px; }
.level-mark { font-weight: 800; }
.check-summary { margin: 4px 0 0; font-weight: 600; }
.check-why { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.check details { margin-top: 8px; }
.check summary { cursor: pointer; font-weight: 600; color: var(--gold); min-height: 32px; display: inline-flex; align-items: center; }
.items { margin: 6px 0 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: .93rem; }
.items li::marker { color: var(--c); }
.item-warning::marker { color: var(--warn) !important; } .item-info::marker { color: var(--info) !important; }
.cut { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }

/* about and footer */
.about { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); max-width: 90ch; }
.about h2 { font-size: clamp(1.7rem, 3.2vw, 2.2rem); margin: 0 0 12px; }
.about p { margin: 0 0 10px; }
.foot { border-top: 1px solid var(--line); padding: 20px 0 60px; color: var(--muted); font-size: .9rem; }
.foot p { margin: 0 0 6px; max-width: 80ch; }

/* narrow screens */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .open { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 1.2rem; }
  th, td { padding: 6px 8px; }
  .drop { padding: 20px 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media print {
  .toolbar, .open, .res-actions, .res-nav, .skip { display: none; }
  .check details { display: block; }
}
