/* ===== Tokens ===== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #16181d;
  --muted: #586071;
  --border: #dfe3ec;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-contrast: #ffffff;
  --accent-soft: #eceeff;
  --ok: #0b6b41;
  --ok-bg: #e4f5ec;
  --bad: #a92318;
  --bad-bg: #fdeceb;
  --warn: #7a4f00;
  --warn-bg: #fff4dc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 6px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #161922;
    --surface-2: #1d212c;
    --text: #eceef4;
    --muted: #a3abbd;
    --border: #2a303d;
    --accent: #8f8bff;
    --accent-hover: #a7a4ff;
    --accent-contrast: #0e1015;
    --accent-soft: #222449;
    --ok: #55d89f;
    --ok-bg: #11291f;
    --bad: #ff8f85;
    --bad-bg: #331a1c;
    --warn: #f4c569;
    --warn-bg: #2d2412;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-block: 1.25rem 3rem; }
.wrap { width: 100%; max-width: 980px; margin-inline: auto; padding-inline: 16px; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6rem; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.65rem, 4.5vw, 2.35rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin-top: 2rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.25rem; margin: 0 0 1rem; }
li { margin-bottom: 0.35rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 68ch; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-contrast); padding: 8px 14px; z-index: 10; border-radius: 0 0 8px 0; }
.skip:focus { left: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, kbd { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 6px; }
table { border-collapse: collapse; width: 100%; margin: 0 0 1rem; font-size: 0.95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* ===== Cabeçalho e rodapé ===== */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark { color: var(--accent); flex: none; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.main-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding-block: 2rem 1.5rem; }
.footer-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.footer-title { font-weight: 700; margin-bottom: 0.5rem; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { margin-bottom: 0.3rem; }
.plain a { text-decoration: none; }
.plain a:hover { text-decoration: underline; }
.copy { margin-top: 1.5rem; margin-bottom: 0; }

/* ===== Home ===== */
.hero { padding-block: 1.5rem 0.5rem; }
.cat h2 { margin-top: 2.25rem; margin-bottom: 0.2rem; }
.card-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 0.8rem; }
.tool-card { display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: border-color 0.15s, transform 0.15s; }
.tool-card:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.tool-icon { flex: none; width: 42px; height: 42px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); border-radius: 10px; font-weight: 700; font-size: 1.1rem; }
.tool-card-body { display: flex; flex-direction: column; gap: 2px; line-height: 1.35; }
.why { margin-top: 2.5rem; }

/* ===== Páginas de ferramenta ===== */
.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 0.9rem; }
.crumbs a { color: var(--muted); }
.tool-head { margin-bottom: 1.1rem; }
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(14px, 3vw, 24px); margin-bottom: 2rem; }
.prose { max-width: 74ch; }
.prose.page { max-width: 74ch; }
.prose h2:first-child { margin-top: 0; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 12px 14px; font-weight: 600; }
.faq-a { padding: 0 14px 12px; }
.faq-a p:last-child { margin-bottom: 0; }
.related { margin-top: 2.5rem; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 14px; font-size: 0.92rem; }
.callout { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; }

/* ===== Formulários e botões ===== */
label { font-weight: 600; font-size: 0.95rem; }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}
textarea { min-height: 220px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 150px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-contrast); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); color: var(--accent); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 6px; }

/* ===== Calculadora de porcentagem ===== */
.calc-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .calc-grid { grid-template-columns: 1fr 1fr; } }
.calc-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.calc-card h3 { margin: 0; font-size: 1rem; }
.calc-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calc-line input { width: 5.75rem; flex: 0 1 6rem; min-width: 0; padding-inline: 8px; }
.calc-line span { color: var(--muted); }
.calc-out { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; min-height: 3.2rem; font-size: 1.02rem; }
.calc-out strong { color: var(--accent); font-size: 1.15em; }
.calc-out .how { display: block; margin-top: 2px; color: var(--muted); font-size: 0.85rem; }
.calc-out.err { color: var(--muted); }

/* ===== Contadores ===== */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-top: 14px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.85rem; }
.limits { display: grid; gap: 10px; margin-top: 8px; }
.limit { font-size: 0.92rem; }
.limit-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.15s; }
.limit.over .bar > i { background: var(--bad); }
.limit.over .limit-top b { color: var(--bad); }
.kw-table td:nth-child(n+2), .kw-table th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Geradores e validadores ===== */
.gen-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.gen-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px 8px 8px 14px; margin: 0; }
.gen-list code { background: none; font-size: 1.15rem; padding: 0; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.verdict { margin-top: 14px; border-radius: 10px; padding: 12px 14px; font-weight: 600; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict small { display: block; font-weight: 400; margin-top: 2px; }
.detail { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 0.95rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }

/* ===== Resultados de datas ===== */
.results { margin-top: 14px; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.big-result { margin-top: 14px; background: var(--surface-2); border-radius: 10px; padding: 14px; font-size: 1.1rem; }
.big-result strong { color: var(--accent); font-size: 1.3em; }
.split { display: grid; gap: 22px; }
@media (min-width: 860px) { .split { grid-template-columns: 1fr 1fr; gap: 32px; } .split > section + section { border-left: 1px solid var(--border); padding-left: 32px; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .actions, .related { display: none; }
}
