:root {
  --ink: #16212b;
  --ink-2: #2b3945;
  --muted: #5b6874;
  --paper: #f1f4f6;
  --surface: #ffffff;
  --line: #d9e0e6;
  --line-strong: #b9c4ce;
  --wind: #245b84;
  --wind-deep: #173f5e;
  --wind-soft: #e3edf5;
  --ok: #2d7a4b;
  --ok-soft: #e4f2e9;
  --warn: #8f5d00;
  --warn-soft: #fbf0d9;
  --bad: #a93442;
  --bad-soft: #f8e4e7;
  --radius: 6px;
  --font: "Public Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--paper); }
a { color: var(--wind); }
a:hover { color: var(--wind-deep); }
code, pre, .mono { font-family: var(--mono); font-size: .86em; }
:focus-visible { outline: 2px solid var(--wind); outline-offset: 2px; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 650; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Estrutura */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #c9d4dd; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.25rem 1.25rem 1rem; color: #fff; text-decoration: none; }
.brand svg { width: 38px; height: 26px; color: #8cb8d8; flex: none; }
.brand span { font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; line-height: 1.1; }
.brand small { display: block; font-weight: 400; font-size: .74rem; color: #93a3b1; letter-spacing: 0; }
.brand:hover { color: #fff; }
.sidebar nav { padding: .25rem .75rem 1rem; flex: 1; }
.nav-group { margin: 1rem .5rem .35rem; font-size: .76rem; color: #7f909e; font-weight: 600; }
.sidebar nav a { display: block; padding: .42rem .6rem; border-radius: var(--radius); color: #d4dde4; text-decoration: none; font-size: .92rem; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--wind); color: #fff; }
.sidebar-foot { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; display: flex; justify-content: space-between; gap: .5rem; }
.sidebar-foot a { color: #9fc3de; }

.main { padding: 0 2rem 3rem; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 1.5rem 0 1.25rem; }
.topbar h1 { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.menu-toggle { display: none; }

/* Blocos */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel > h2:first-child { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.panel-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 1.25rem; }
.figures div { padding: 1rem 1.25rem; border-right: 1px solid var(--line); }
.figures div:last-child { border-right: 0; }
.figures strong { display: block; font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.figures span { color: var(--muted); font-size: .88rem; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; align-items: baseline; }
.checklist li:last-child { border-bottom: 0; }
.checklist .state { flex: none; width: 1.2rem; text-align: center; font-weight: 700; }
.checklist .done .state { color: var(--ok); }
.checklist .todo .state { color: var(--warn); }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .82rem; background: #f8fafb; white-space: nowrap; }
tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
td .title { font-weight: 550; color: var(--ink); text-decoration: none; }
td .title:hover { color: var(--wind); text-decoration: underline; }
td .sub { display: block; color: var(--muted); font-size: .82rem; }
.is-hidden td { opacity: .55; }

/* Formulários */
label { display: block; font-weight: 550; font-size: .88rem; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .6rem; font: inherit; font-weight: 400; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius);
}
textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: .85rem; }
input:focus, select:focus, textarea:focus { border-color: var(--wind); outline: 2px solid var(--wind-soft); }
input[type=file] { margin-top: .3rem; font: inherit; font-size: .88rem; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.check input { width: 1rem; height: 1rem; }
.stack > * + * { margin-top: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; align-items: center; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters label { flex: 1 1 150px; }
.filters .grow { flex: 2 1 240px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 650; padding: 0 .35rem; font-size: .92rem; }
.inline-form { display: inline; }

/* Botões */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .95rem; font: inherit; font-weight: 600; font-size: .9rem;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn-primary { background: var(--wind); border-color: var(--wind); color: #fff; }
.btn-primary:hover { background: var(--wind-deep); border-color: var(--wind-deep); color: #fff; }
.btn-danger { color: var(--bad); border-color: #e0b7bd; }
.btn-danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-sm { padding: .28rem .6rem; font-size: .82rem; }
.btn-link { background: none; border: 0; padding: 0; color: var(--wind); font: inherit; cursor: pointer; text-decoration: underline; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* Hash do link: o elemento central do sistema */
.chip { display: inline-flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #f7f9fb; max-width: 100%; }
.chip a { padding: .2rem .5rem; text-decoration: none; color: var(--wind-deep); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip a code { font-size: .8rem; }
.chip .copy { border: 0; border-left: 1px solid var(--line-strong); background: transparent; padding: 0 .55rem; font: inherit; font-size: .76rem; color: var(--muted); cursor: pointer; }
.chip .copy:hover { color: var(--wind); background: var(--wind-soft); }
.chip .copy.copied { color: var(--ok); }
.link-hero { border: 1px solid var(--wind); background: var(--wind-soft); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1.25rem; }
.link-hero p { margin: 0 0 .4rem; font-size: .86rem; color: var(--wind-deep); font-weight: 600; }
.link-hero .chip { background: #fff; font-size: 1rem; }
.link-hero .chip a code { font-size: .92rem; }

/* Selos */
.badge { display: inline-block; padding: .08rem .45rem; border-radius: 4px; font-size: .76rem; font-weight: 600; background: #eef1f4; color: var(--ink-2); white-space: nowrap; }
.badge-documentos-cvm { background: #e3edf5; color: #1d4c70; }
.badge-central-de-resultados { background: #e6f0e4; color: #2f5d2a; }
.badge-comunicados-e-atas { background: #f3e9dc; color: #6e4a17; }
.badge-oculto { background: #eceef0; color: #6a747d; }
.tag-ok { color: var(--ok); font-weight: 600; }
.tag-bad { color: var(--bad); font-weight: 600; }
.tag-warn { color: var(--warn); font-weight: 600; }

/* Alertas */
.alert { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.alert-success { background: var(--ok-soft); border-color: #b9dcc5; color: #1f5a36; }
.alert-error { background: var(--bad-soft); border-color: #e7bcc2; color: #7d1f2c; }
.alert-warning { background: var(--warn-soft); border-color: #ecd3a0; color: #6b4600; }
.alert-info { background: var(--wind-soft); border-color: #bcd3e5; color: var(--wind-deep); }
.new-key { font-family: var(--mono); font-size: 1rem; padding: .6rem .8rem; background: #fff; border: 1px dashed var(--wind); border-radius: var(--radius); word-break: break-all; display: block; margin: .5rem 0; }

/* Abas */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--wind); }

/* Paginação */
.pager { display: flex; gap: .35rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.pager a, .pager span { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 4px; text-decoration: none; font-size: .88rem; }
.pager .current { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Console de testes */
.test-card { display: flex; flex-direction: column; }
.test-card form { flex: 1; display: flex; flex-direction: column; }
.test-card .form-actions { margin-top: auto; padding-top: .9rem; }
.test-card p.muted { font-size: .88rem; }
.console { background: #101a22; color: #d7e3ec; border-radius: var(--radius); padding: 1rem 1.1rem; font-family: var(--mono); font-size: .8rem;
  white-space: pre-wrap; word-break: break-word; max-height: 520px; overflow: auto; margin: 0; }
.console .k { color: #8cb8d8; }
.console .ok { color: #8fd3a5; }
.console .bad { color: #f2a2ad; }
.console-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.sticky-console { position: sticky; top: 1rem; }

pre.code { background: #101a22; color: #d7e3ec; padding: .9rem 1rem; border-radius: var(--radius); overflow-x: auto; font-size: .8rem; margin: .5rem 0 1rem; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; font-size: .9rem; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; word-break: break-word; }

/* Login */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; background: var(--ink); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 8px; padding: 2rem; }
.brand-dark { padding: 0 0 1.5rem; color: var(--ink); }
.brand-dark svg { color: var(--wind); }
.brand-dark small { color: var(--muted); }
.auth-title { font-size: 1.2rem; margin: 0 0 1rem; }
.auth .btn-primary { width: 100%; justify-content: center; padding: .65rem; }

@media (max-width: 1100px) {
  .split, .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figures div:nth-child(2) { border-right: 0; }
  .figures div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .sticky-console { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .menu-toggle { display: inline-flex; padding: .35rem .7rem; border: 1px solid var(--line-strong); background: #fff; border-radius: var(--radius); font: inherit; font-size: .85rem; }
  .main { padding: 0 1rem 2rem; }
  .form-grid, .grid-3 { grid-template-columns: 1fr; }
  th.hide-sm, td.hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
