:root {
  --red: #ee0000; --red-dark: #a60000; --ink: #151515; --ink-2: #4d4d4d; --muted: #6a6e73;
  --bg: #f2f2f2; --surface: #ffffff; --line: #d2d2d2; --line-soft: #e8e8e8; --soft: #f5f5f5;
  --blue: #2a78d6; --blue-dark: #0d366b; --focus: #0066cc; --radius: 6px;
  --display: "Red Hat Display", Overpass, "Helvetica Neue", Arial, sans-serif;
  --text: "Red Hat Text", Overpass, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--text); min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 500; }
h3 { font-size: 1rem; font-weight: 700; margin: 22px 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip, .offscreen { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px 12px; z-index: 99; }
.hint { color: var(--muted); font-size: 0.86rem; margin: 4px 0 0; }
.hint.pad { margin: 0 0 16px; }
.muted { color: var(--muted); }
.mt { margin-top: 28px; }

/* ---- cabeçalho ---- */
.masthead { background: var(--ink); color: #fff; border-bottom: 3px solid var(--red); position: sticky; top: 0; z-index: 20; }
.mast-in { max-width: 1400px; margin: 0 auto; padding: 0 20px; min-height: 60px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand-mark { display: flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.brand-text small { color: #c7c7c7; font-size: 0.72rem; }
.masthead nav { display: flex; gap: 4px; align-self: stretch; }
.masthead nav a { color: #e0e0e0; text-decoration: none; padding: 0 14px; display: flex; align-items: center; font-weight: 500; font-size: 0.95rem; border-bottom: 3px solid transparent; margin-bottom: -3px; white-space: nowrap; }
.masthead nav a:hover { color: #fff; }
.masthead nav a.on { color: #fff; border-bottom-color: #fff; }
.mast-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.badge-role { border: 1px solid #8a8d90; border-radius: 99px; padding: 2px 12px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; max-width: 240px; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang { width: auto; min-height: 34px; flex: none; background: var(--ink); color: #fff; border: 1px solid #6a6e73; border-radius: var(--radius); padding: 6px 8px; font: inherit; font-size: 0.85rem; }

/* ---- página ---- */
main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 28px 20px 48px; }
main.wide { max-width: 1400px; }
main.with-bar { padding-bottom: 110px; }
.footer { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 18px; border-top: 1px solid var(--line); }
.page-head { margin-bottom: 22px; }
.eyebrow { color: var(--red); font-weight: 700; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 6px; }
.lead { color: var(--ink-2); font-size: 1.05rem; max-width: 780px; margin: 10px 0 0; }
.hero { background: radial-gradient(120% 140% at 85% 10%, #5a0f0f 0%, #1f1f1f 45%, #151515 100%); color: #fff; border-radius: var(--radius); padding: clamp(28px, 6vw, 56px); margin-bottom: 20px; }
.hero h1 { font-size: clamp(2rem, 5.5vw, 3.2rem); font-weight: 900; max-width: 640px; }
.hero p { color: #e0e0e0; font-size: 1.1rem; max-width: 640px; margin: 18px 0 0; }
.hero .eyebrow { color: #ff6b6b; }

.card { background: var(--surface); border-radius: var(--radius); padding: 24px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.card.flat { box-shadow: none; border: 1px solid var(--line-soft); }
.card.narrow { max-width: 520px; }
.card.accent-dark { border-top: 3px solid var(--ink); }
.card.accent-red { border-top: 3px solid var(--red); }
.card > h2 { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.card > h2 + .field, .card > h2 + .grid2, .card > h2 + .grid3 { margin-top: 16px; }
.card > .hint { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.step { background: var(--ink); color: #fff; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700; flex: none; }
.grid2, .grid3, .grid4 { display: grid; gap: 18px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: 2fr 1fr 1fr 1fr; }
.grid2.tight, .grid3.tight, .grid4.tight { gap: 4px 20px; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
main > .grid2, main > .grid3 { margin-bottom: 18px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: flex-end; }

/* ---- formulário ---- */
.field { margin: 14px 0; min-width: 0; }
.field > label { display: block; font-weight: 500; font-size: 0.92rem; margin-bottom: 6px; }
.req { color: var(--red); }
input[type=text], input[type=number], input[type=password], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #8a8d90; border-radius: var(--radius); padding: 9px 12px; min-height: 42px; }
textarea { resize: vertical; }
.row > input, .row > select { min-width: 0; }
.row > select { width: auto; flex: none; }
.field.error input, .field.error textarea, .field.error .chips { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); border-radius: var(--radius); }
.field.error > label { color: var(--red-dark); }
.btn { font: inherit; font-weight: 500; font-size: 0.92rem; border-radius: var(--radius); padding: 9px 18px; border: 1px solid transparent; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; min-height: 42px; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: #3c3f42; }
.btn.ghost { background: #fff; color: var(--ink); border-color: #8a8d90; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { color: var(--red-dark); }
.btn:disabled { opacity: 0.55; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 0.9rem; background: #fff; border: 1px solid #8a8d90; border-radius: 99px; padding: 7px 14px; cursor: pointer; color: var(--ink); min-height: 38px; }
.chip:hover { background: var(--soft); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.scale-row { display: flex; align-items: center; gap: 10px; }
.scale-row .chips.scale { flex-wrap: nowrap; }
.scale-row .hint { margin: 0; }
.chips.scale .chip { width: 46px; padding: 7px 0; font-weight: 700; border-radius: var(--radius); }
.scale-note { min-height: 1.3em; margin-top: 8px; }
.option-card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid #8a8d90; border-radius: var(--radius); padding: 14px; cursor: pointer; margin-bottom: 8px; }
.option-card:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--soft); }
.option-card input { margin-top: 4px; accent-color: var(--ink); }
.option-card strong { display: block; font-weight: 500; }
.option-card small { color: var(--muted); font-size: 0.84rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { background: var(--soft); border: 1px solid var(--line); border-radius: 99px; padding: 3px 4px 3px 12px; font-size: 0.86rem; display: inline-flex; align-items: center; gap: 4px; }
.tag button { border: 0; background: none; cursor: pointer; font-size: 1.05rem; line-height: 1; padding: 2px 8px; color: var(--muted); border-radius: 99px; }
.tag button:hover { color: var(--ink); background: var(--line); }
.estimate { background: linear-gradient(100deg, #151515 0%, #1f1f1f 55%, #4a1010 100%); color: #fff; border-left: 4px solid var(--red); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px; }
.estimate h2 { font-weight: 700; }
.estimate > p { color: #c7c7c7; font-size: 0.9rem; margin: 4px 0 14px; }
.estimate-body { display: flex; gap: 14px 40px; flex-wrap: wrap; border: 1px dashed #6a6e73; border-radius: var(--radius); padding: 16px 18px; }
.est-v { font-family: var(--display); font-size: 1.5rem; font-weight: 700; }
.est-v.big { font-size: 2.1rem; line-height: 1.1; }
.est-k { color: #c7c7c7; font-size: 0.82rem; }
.est-empty { margin: 0; color: #c7c7c7; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); z-index: 15; box-shadow: 0 -2px 8px rgba(0,0,0,0.06); }
.action-in { max-width: 1040px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress { color: var(--muted); font-size: 0.85rem; }
.success { text-align: center; margin: 40px auto; padding: 40px 28px; }
.success .lead { margin: 10px auto 6px; }
.check { width: 60px; height: 60px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 1.8rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.mine-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.empty { color: var(--muted); margin: 8px 0 0; }
.empty-state { text-align: center; padding: 56px 24px; }
.formula { background: var(--soft); border-radius: var(--radius); padding: 12px 14px; font: 0.82rem/1.6 "Red Hat Mono", ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; margin: 0; color: var(--ink-2); }
.lens { border-left: 3px solid var(--line); padding: 2px 0 2px 14px; margin: 8px 0; }

/* ---- painel ---- */
.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 24px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 500; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 16px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.tabs button:hover { color: var(--ink); border-bottom-color: var(--line); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--red); }
.filters { display: flex; gap: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; min-height: 38px; padding: 6px 10px; font-size: 0.9rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.kpi-k { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.kpi-v { font-family: var(--display); font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.kpi-s { color: var(--muted); font-size: 0.8rem; }
.split { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.card-head select, .heat-controls select { width: auto; min-height: 38px; padding: 6px 10px; font-size: 0.9rem; }
.chart { margin-top: 12px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .tick { font: 11px var(--text); fill: var(--muted); }
.chart-svg .axis-title { font: 500 12px var(--text); fill: var(--ink-2); }
.chart-svg .corner { font: 700 11px var(--display); fill: #8a8d90; letter-spacing: 0.08em; }
.chart-svg .bubble { cursor: pointer; outline: none; }
.chart-svg .bubble:hover circle, .chart-svg .bubble:focus-visible circle { stroke: var(--ink); fill-opacity: 1; }
.chart-svg .bubble-rank { font: 700 11px var(--text); pointer-events: none; }
.legend { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; margin-top: 10px; font-size: 0.8rem; color: var(--ink-2); }
.legend-title { font-weight: 500; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-note { color: var(--muted); }
.swatch { width: 22px; height: 12px; display: inline-block; }
.swatch.dot { width: 12px; height: 12px; border-radius: 50%; }
.heat-scale { display: inline-flex; gap: 2px; }
.tip { position: fixed; z-index: 60; background: var(--ink); color: #fff; border-radius: var(--radius); padding: 10px 12px; font-size: 0.8rem; max-width: 300px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,0.25); }
.tip[hidden] { display: none; }
.tip-title { font-weight: 700; margin-bottom: 6px; }
.tip-row { display: flex; justify-content: space-between; gap: 18px; }
.tip-k { color: #c7c7c7; }
.ranking { list-style: none; margin: 10px 0 0; padding: 0; }
.ranking li { border-top: 1px solid var(--line-soft); }
.ranking button { width: 100%; display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 10px 4px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.ranking button:hover { background: var(--soft); }
.rank { width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 0.78rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.rank-main { flex: 1; min-width: 0; }
.rank-main strong { display: block; font-weight: 500; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-main small { color: var(--muted); font-size: 0.78rem; }
.rank-score { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
.heat-controls { display: flex; gap: 10px 20px; flex-wrap: wrap; margin: 14px 0 4px; }
.heat-controls label { font-size: 0.85rem; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.heat-wrap, .table-wrap { overflow-x: auto; }
.heat { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 0.86rem; }
.heat th { font-weight: 500; text-align: left; padding: 6px 10px; color: var(--ink-2); white-space: nowrap; }
.heat thead th { text-align: center; font-size: 0.78rem; white-space: normal; vertical-align: bottom; min-width: 76px; }
.heat thead th.heat-corner { text-align: left; color: var(--muted); font-weight: 400; }
.heat td { padding: 0; text-align: center; min-width: 76px; }
.heat-cell { width: 100%; min-height: 42px; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; border-radius: 3px; }
.heat-cell:hover, .heat-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.heat-empty { color: var(--line); background: var(--soft); border-radius: 3px; }
.heat td.heat-empty { padding: 9px 0; }
.heat .heat-total { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; padding: 6px 10px; text-align: right; }
.heat tfoot .heat-total { text-align: center; }
.waves { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.wave { background: #e8e8e8; border-radius: var(--radius); padding: 16px 12px 8px; border-top: 3px solid var(--ink); }
.wave > h2 { font-weight: 700; padding: 0 4px; }
.wave > .hint { min-height: 3.6em; padding: 0 4px; }
.wave-total { font-size: 0.84rem; color: var(--ink-2); margin: 8px 4px 12px; }
.wave-card { display: block; width: 100%; text-align: left; background: #fff; border: 0; border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; font: inherit; color: inherit; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.wave-card:hover { box-shadow: 0 0 0 2px var(--ink); }
.wave-card strong { display: block; font-weight: 500; font-size: 0.9rem; }
.wave-card small { display: block; color: var(--muted); font-size: 0.78rem; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
table.data th { text-align: left; border-bottom: 2px solid var(--line); padding: 0; white-space: nowrap; }
table.data th button { font: inherit; font-weight: 700; font-size: 0.8rem; background: none; border: 0; padding: 8px 10px; cursor: pointer; color: var(--ink-2); }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data td.n, .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.link { font: inherit; font-weight: 500; background: none; border: 0; padding: 0; color: var(--focus); cursor: pointer; text-align: left; }
.link:hover { text-decoration: underline; }
.pill { display: inline-block; border: 1px solid var(--line); border-radius: 99px; padding: 1px 10px; font-size: 0.76rem; font-weight: 500; white-space: nowrap; background: #fff; color: var(--ink-2); vertical-align: middle; }
.pill.q-quick_win { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill.q-strategic { border-color: var(--ink); color: var(--ink); }
.company.off { opacity: 0.7; }
.link-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.link-row .hint { width: 130px; margin: 0; }
.link-row code { flex: 1; min-width: 200px; background: var(--soft); border-radius: var(--radius); padding: 9px 12px; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- gaveta de detalhe ---- */
#overlay { display: none; }
#overlay.open { display: block; position: fixed; inset: 0; z-index: 40; }
.scrim { position: absolute; inset: 0; background: rgba(21,21,21,0.55); }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: #fff; display: flex; flex-direction: column; box-shadow: -6px 0 24px rgba(0,0,0,0.2); }
.drawer.wide { width: min(680px, 100%); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 22px; border-bottom: 3px solid var(--red); background: var(--ink); color: #fff; }
.drawer-head h2 { font-weight: 700; }
.drawer-head .btn { min-height: 34px; padding: 4px 10px; }
.drawer-body { padding: 20px 22px 32px; overflow-y: auto; }
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.desc { white-space: pre-wrap; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.patterns ul { margin: 0; padding-left: 18px; font-size: 0.9rem; }
.patterns li { margin-bottom: 4px; }
.chain { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.chain.total { background: var(--ink); color: #fff; border-color: var(--ink); }
.chain-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.chain .score { font-family: var(--display); font-weight: 700; font-size: 1.25rem; }
.chain table { width: 100%; border-collapse: collapse; font-size: 0.84rem; margin-top: 6px; }
.chain td { padding: 4px 6px 4px 0; border-top: 1px solid var(--line-soft); vertical-align: top; }
.chain td:first-child { color: var(--muted); width: 36%; }
.triage { background: var(--soft); border-radius: var(--radius); padding: 4px 18px 18px; margin-top: 22px; }
#toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--radius); font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 70; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--red-dark); }

@media (max-width: 1000px) {
  .brand-text small { display: none; }
  .split { grid-template-columns: 1fr; }
  .waves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .mast-in { flex-wrap: wrap; gap: 6px 14px; padding: 8px 14px 0; }
  .brand-text small { display: none; }
  .masthead nav { order: 3; width: 100%; overflow-x: auto; }
  .masthead nav a { padding: 10px 12px; font-size: 0.88rem; white-space: nowrap; }
  .badge-role { max-width: 130px; }
  main { padding: 20px 14px 40px; }
  .card { padding: 18px 16px; }
  .grid2, .grid3, .grid4, .waves { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 8px; }
  .link-row .hint { width: 100%; }
  .wave > .hint { min-height: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .masthead nav, .mast-right, .action-bar, .filters, .footer, #toast { display: none !important; }
  .masthead { position: static; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
}
