/* ==========================================================================
   Margem — sistema visual
   Identidade própria, sem dependências externas: nenhuma fonte remota, nenhum
   framework. Tudo em variáveis CSS para que o tema claro e o escuro dividam a
   mesma folha.
   ========================================================================== */

:root {
  /* Marca */
  --brand-900: #062b26;
  --brand-800: #0a3d35;
  --brand-700: #0d5347;
  --brand-600: #106b5b;
  --brand-500: #14856f;
  --brand-400: #37a68e;
  --brand-300: #6cc4b1;
  --brand-100: #d7efe9;
  --accent: #d99b2b;
  --accent-soft: #fbf1dd;

  /* Semáforo */
  --verde: #10795f;
  --verde-soft: #dcf2ec;
  --ambar: #b3730a;
  --ambar-soft: #fdf0da;
  --vermelho: #b23c34;
  --vermelho-soft: #fbe6e3;

  /* Superfícies */
  --canvas: #f2f5f6;
  --surface: #ffffff;
  --surface-2: #f8fafa;
  --surface-3: #eef2f3;
  --sidebar: #062b26;
  --sidebar-hover: #0d4239;
  --sidebar-active: #14856f;

  /* Texto */
  --texto: #16241f;
  --texto-2: #4b6058;
  --texto-3: #7b8f87;
  --texto-invertido: #eaf5f2;

  /* Traços */
  --borda: #dde5e4;
  --borda-forte: #c3d1ce;
  --anel: rgba(20, 133, 111, 0.28);

  /* Formas */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --sombra-1: 0 1px 2px rgba(6, 43, 38, 0.06), 0 1px 3px rgba(6, 43, 38, 0.04);
  --sombra-2: 0 4px 12px rgba(6, 43, 38, 0.08), 0 1px 3px rgba(6, 43, 38, 0.05);
  --sombra-3: 0 18px 45px rgba(6, 43, 38, 0.18);

  --fonte: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --fonte-num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo,
    Consolas, monospace;
}

[data-tema="escuro"] {
  --canvas: #0b1513;
  --surface: #10201d;
  --surface-2: #142825;
  --surface-3: #1a322e;
  --sidebar: #071411;
  --sidebar-hover: #14302a;
  --sidebar-active: #14856f;

  --texto: #e4efec;
  --texto-2: #a5bcb5;
  --texto-3: #7a938c;

  --borda: #21403a;
  --borda-forte: #2d5750;

  --brand-100: #14302a;
  --verde-soft: #10332b;
  --ambar-soft: #33280f;
  --vermelho-soft: #351d1a;
  --accent-soft: #322810;

  --sombra-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sombra-2: 0 4px 14px rgba(0, 0, 0, 0.35);
  --sombra-3: 0 18px 45px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------------------------ base -- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--fonte);
  font-size: 15px;
  line-height: 1.5;
  color: var(--texto);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--texto);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.875rem; }

p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--brand-600);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

hr {
  border: 0;
  border-top: 1px solid var(--borda);
  margin: 1.25rem 0;
}

::selection {
  background: var(--brand-300);
  color: var(--brand-900);
}

/* --------------------------------------------------------------- layout -- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: var(--sidebar);
  color: var(--texto-invertido);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__marca {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__logo {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-600));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.03em;
}

.sidebar__nome {
  font-weight: 650;
  font-size: 1.02rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.sidebar__sub {
  font-size: 0.72rem;
  color: rgba(234, 245, 242, 0.55);
  line-height: 1.2;
  margin-top: 2px;
}

.sidebar__nav {
  padding: 0.75rem 0.6rem;
  flex: 1;
}

.sidebar__grupo {
  padding: 0.9rem 0.7rem 0.35rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(234, 245, 242, 0.4);
  font-weight: 600;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--r-sm);
  color: rgba(234, 245, 242, 0.82);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.sidebar__link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.sidebar__link[aria-current="page"] {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar__link svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  opacity: 0.85;
}

.sidebar__rodape {
  padding: 0.9rem 1rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  color: rgba(234, 245, 242, 0.55);
}

.sidebar__usuario {
  color: var(--texto-invertido);
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
  word-break: break-all;
}

.conteudo {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topo {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--borda);
  padding: 0.8rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.topo__titulo { flex: 1; min-width: 180px; }
.topo__titulo h1 { font-size: 1.2rem; }
.topo__titulo p {
  margin: 1px 0 0;
  font-size: 0.82rem;
  color: var(--texto-3);
}

.topo__acoes {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.principal {
  padding: 1.5rem;
  flex: 1;
  max-width: 1480px;
  width: 100%;
}

.menu-botao {
  display: none;
  background: none;
  border: 1px solid var(--borda);
  border-radius: var(--r-sm);
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  color: var(--texto);
}

/* ---------------------------------------------------------------- grade -- */

.grade { display: grid; gap: 1rem; }
.grade--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grade--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grade--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grade--etapas { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; }
.grade--auto { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.pilha { display: flex; flex-direction: column; gap: 1rem; }
.linha { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.linha--entre { justify-content: space-between; }
.crescer { flex: 1; }

/* ---------------------------------------------------------------- cartão -- */

.cartao {
  background: var(--surface);
  border: 1px solid var(--borda);
  border-radius: var(--r-lg);
  box-shadow: var(--sombra-1);
  overflow: hidden;
}

.cartao__topo {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--borda);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--surface-2);
}

.cartao__topo h2,
.cartao__topo h3 { flex: 1; min-width: 140px; }

.cartao__etapa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex: 0 0 24px;
}

.cartao__corpo { padding: 1.15rem; }
.cartao__corpo--compacto { padding: 0.85rem 1.15rem; }

.cartao__rodape {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--borda);
  background: var(--surface-2);
}

.cartao__legenda {
  font-size: 0.8rem;
  color: var(--texto-3);
  margin: 0;
}

/* ------------------------------------------------------------ formulário -- */

.campo { margin-bottom: 0.9rem; }
.campo:last-child { margin-bottom: 0; }

.campo__rotulo {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--texto-2);
  margin-bottom: 0.3rem;
}

.campo__dica {
  font-size: 0.75rem;
  color: var(--texto-3);
  margin-top: 0.25rem;
}

.campo__erro {
  font-size: 0.78rem;
  color: var(--vermelho);
  margin-top: 0.25rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--texto);
  background: var(--surface);
  border: 1px solid var(--borda-forte);
  border-radius: var(--r-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
  appearance: none;
}

input[type="number"] { font-family: var(--fonte-num); }

textarea { resize: vertical; min-height: 74px; line-height: 1.45; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237b8f87' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 1.8rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--anel);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-3);
  color: var(--texto-3);
  cursor: not-allowed;
}

input::placeholder,
textarea::placeholder { color: var(--texto-3); }

.grupo-campo {
  display: flex;
  align-items: stretch;
}

.grupo-campo > input,
.grupo-campo > select { border-radius: 0; }
.grupo-campo > *:first-child {
  border-top-left-radius: var(--r-sm);
  border-bottom-left-radius: var(--r-sm);
}
.grupo-campo > *:last-child {
  border-top-right-radius: var(--r-sm);
  border-bottom-right-radius: var(--r-sm);
}
.grupo-campo > * + * { margin-left: -1px; }
.grupo-campo > *:focus { z-index: 2; }

.grupo-campo__afixo {
  display: flex;
  align-items: center;
  padding: 0 0.55rem;
  background: var(--surface-3);
  border: 1px solid var(--borda-forte);
  color: var(--texto-3);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.grupo-campo__modo {
  flex: 0 0 120px;
  background: var(--surface-2);
  font-size: 0.78rem;
}

.marcador {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--texto-2);
  cursor: pointer;
  padding: 0.15rem 0;
}

.marcador input[type="checkbox"],
.marcador input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--brand-600);
  flex: 0 0 16px;
  cursor: pointer;
}

.segmentado {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 3px;
}

.segmentado label {
  position: relative;
  cursor: pointer;
}

.segmentado input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.segmentado span {
  display: block;
  padding: 0.32rem 0.75rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--texto-2);
  white-space: nowrap;
}

.segmentado input:checked + span {
  background: var(--surface);
  color: var(--brand-700);
  box-shadow: var(--sombra-1);
}

.segmentado input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--anel);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1.15rem;
}

fieldset:last-child { margin-bottom: 0; }

.secao-titulo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--texto-3);
  margin: 0 0 0.7rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--borda);
}

/* --------------------------------------------------------------- botões -- */

.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-decoration: none;
}

.botao:hover { text-decoration: none; }
.botao:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--anel); }
.botao:disabled { opacity: 0.55; cursor: not-allowed; }

.botao svg { width: 15px; height: 15px; }

.botao--primario {
  background: var(--brand-600);
  color: #fff;
}
.botao--primario:hover { background: var(--brand-700); color: #fff; }

.botao--secundario {
  background: var(--surface);
  border-color: var(--borda-forte);
  color: var(--texto);
}
.botao--secundario:hover { background: var(--surface-3); color: var(--texto); }

.botao--fantasma {
  background: transparent;
  color: var(--texto-2);
}
.botao--fantasma:hover { background: var(--surface-3); color: var(--texto); }

.botao--perigo {
  background: var(--surface);
  border-color: var(--borda-forte);
  color: var(--vermelho);
}
.botao--perigo:hover { background: var(--vermelho-soft); }

.botao--pequeno {
  padding: 0.3rem 0.6rem;
  font-size: 0.79rem;
  gap: 0.3rem;
}
.botao--pequeno svg { width: 13px; height: 13px; }

.botao--icone {
  padding: 0.35rem;
  width: 30px;
  height: 30px;
}

.botao--bloco { width: 100%; }

/* -------------------------------------------------------------- selos -- */

.selo {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.005em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.selo--verde { background: var(--verde-soft); color: var(--verde); }
.selo--ambar { background: var(--ambar-soft); color: var(--ambar); }
.selo--vermelho { background: var(--vermelho-soft); color: var(--vermelho); }
.selo--neutro { background: var(--surface-3); color: var(--texto-2); }
.selo--marca { background: var(--brand-100); color: var(--brand-700); }

.selo__ponto {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ------------------------------------------------------------- semáforo -- */

.semaforo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid;
}

.semaforo--verde { background: var(--verde-soft); border-color: color-mix(in srgb, var(--verde) 25%, transparent); }
.semaforo--amarelo { background: var(--ambar-soft); border-color: color-mix(in srgb, var(--ambar) 25%, transparent); }
.semaforo--vermelho { background: var(--vermelho-soft); border-color: color-mix(in srgb, var(--vermelho) 25%, transparent); }

.semaforo__luz {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  color: #fff;
}

.semaforo--verde .semaforo__luz { background: var(--verde); }
.semaforo--amarelo .semaforo__luz { background: var(--ambar); }
.semaforo--vermelho .semaforo__luz { background: var(--vermelho); }

.semaforo__texto { flex: 1; min-width: 0; }

.semaforo__titulo {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0;
}

.semaforo--verde .semaforo__titulo { color: var(--verde); }
.semaforo--amarelo .semaforo__titulo { color: var(--ambar); }
.semaforo--vermelho .semaforo__titulo { color: var(--vermelho); }

.semaforo__motivos {
  margin: 0.2rem 0 0;
  padding-left: 1rem;
  font-size: 0.82rem;
  color: var(--texto-2);
}

/* ------------------------------------------------------------- métricas -- */

.metrica {
  background: var(--surface);
  border: 1px solid var(--borda);
  border-radius: var(--r-md);
  padding: 0.9rem 1rem;
}

.metrica__rotulo {
  font-size: 0.75rem;
  color: var(--texto-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.3rem;
}

.metrica__valor {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--texto);
}

.metrica__valor--verde { color: var(--verde); }
.metrica__valor--vermelho { color: var(--vermelho); }
.metrica__valor--grande { font-size: 1.85rem; }

.metrica__nota {
  font-size: 0.76rem;
  color: var(--texto-3);
  margin: 0.25rem 0 0;
}

.metrica--destaque {
  background: linear-gradient(150deg, var(--brand-700), var(--brand-500));
  border-color: transparent;
  color: #fff;
}
.metrica--destaque .metrica__rotulo { color: rgba(255, 255, 255, 0.72); }
.metrica--destaque .metrica__valor { color: #fff; }
.metrica--destaque .metrica__nota { color: rgba(255, 255, 255, 0.72); }

/* --------------------------------------------------------------- tabela -- */

.tabela-envolvente {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.tabela th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--texto-3);
  font-weight: 700;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--borda);
  white-space: nowrap;
  background: var(--surface-2);
}

.tabela td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--borda);
  vertical-align: middle;
}

.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover { background: var(--surface-2); }

.tabela .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tabela th.num { text-align: right; }

.tabela tr.destaque td {
  background: var(--brand-100);
  font-weight: 700;
}

.tabela tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--borda-forte);
  background: var(--surface-2);
}

.tabela--enxuta td,
.tabela--enxuta th { padding: 0.4rem 0.55rem; }

/* ------------------------------------------------------- detalhamento -- */

.detalhe-linha {
  display: grid;
  grid-template-columns: 1fr auto 74px;
  gap: 0.6rem;
  align-items: center;
  padding: 0.42rem 0;
  border-bottom: 1px dashed var(--borda);
  font-size: 0.87rem;
}

.detalhe-linha:last-child { border-bottom: 0; }

.detalhe-linha__valor {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.detalhe-linha__pct {
  font-size: 0.78rem;
  color: var(--texto-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detalhe-linha--total {
  border-top: 2px solid var(--borda-forte);
  border-bottom: 0;
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.barra-participacao {
  display: flex;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  margin-bottom: 0.75rem;
}

.barra-participacao span { display: block; height: 100%; }

.barra-participacao span:nth-child(1) { background: var(--brand-600); }
.barra-participacao span:nth-child(2) { background: var(--brand-400); }
.barra-participacao span:nth-child(3) { background: var(--accent); }
.barra-participacao span:nth-child(4) { background: var(--brand-300); }
.barra-participacao span:nth-child(5) { background: var(--texto-3); }

.legenda-participacao {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.79rem;
  color: var(--texto-2);
}

.legenda-participacao li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}

.legenda-participacao i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: 0 0 9px;
}

.legenda-participacao li:nth-child(1) i { background: var(--brand-600); }
.legenda-participacao li:nth-child(2) i { background: var(--brand-400); }
.legenda-participacao li:nth-child(3) i { background: var(--accent); }
.legenda-participacao li:nth-child(4) i { background: var(--brand-300); }
.legenda-participacao li:nth-child(5) i { background: var(--texto-3); }

.legenda-participacao ul { margin: 0; padding: 0; }

/* -------------------------------------------------------------- sanfona -- */

details.sanfona {
  border: 1px solid var(--borda);
  border-radius: var(--r-md);
  background: var(--surface);
  margin-bottom: 0.7rem;
}

details.sanfona[open] { box-shadow: var(--sombra-1); }

details.sanfona > summary {
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--texto);
  border-radius: var(--r-md);
}

details.sanfona > summary::-webkit-details-marker { display: none; }

details.sanfona > summary::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--texto-3);
  border-bottom: 2px solid var(--texto-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}

details.sanfona[open] > summary::after {
  transform: rotate(-135deg) translateY(-2px);
}

details.sanfona > summary:hover { background: var(--surface-2); }

.sanfona__corpo {
  padding: 0 0.95rem 0.95rem;
  border-top: 1px solid var(--borda);
  padding-top: 0.85rem;
}

/* -------------------------------------------------------------- avisos -- */

.aviso {
  display: flex;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-md);
  font-size: 0.85rem;
  border: 1px solid;
  margin-bottom: 0.7rem;
}

.aviso:last-child { margin-bottom: 0; }
.aviso svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: 1px; }
.aviso p { margin: 0; }
.aviso ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }

.aviso--info { background: var(--brand-100); border-color: color-mix(in srgb, var(--brand-500) 25%, transparent); color: var(--brand-800); }
.aviso--atencao { background: var(--ambar-soft); border-color: color-mix(in srgb, var(--ambar) 25%, transparent); color: var(--ambar); }
.aviso--erro { background: var(--vermelho-soft); border-color: color-mix(in srgb, var(--vermelho) 25%, transparent); color: var(--vermelho); }
.aviso--sucesso { background: var(--verde-soft); border-color: color-mix(in srgb, var(--verde) 25%, transparent); color: var(--verde); }

[data-tema="escuro"] .aviso--info { color: var(--brand-300); }

.nota-legal {
  font-size: 0.78rem;
  color: var(--texto-3);
  line-height: 1.45;
  border-left: 3px solid var(--borda-forte);
  padding-left: 0.75rem;
}

/* --------------------------------------------------------------- vazio -- */

.vazio {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--texto-3);
}

.vazio svg {
  width: 40px;
  height: 40px;
  opacity: 0.4;
  margin-bottom: 0.6rem;
}

.vazio h3 { color: var(--texto-2); margin-bottom: 0.3rem; }
.vazio p { font-size: 0.87rem; max-width: 380px; margin: 0 auto 0.9rem; }

/* --------------------------------------------------------------- modal -- */

dialog.modal {
  border: 1px solid var(--borda);
  border-radius: var(--r-lg);
  padding: 0;
  width: min(680px, calc(100vw - 2rem));
  background: var(--surface);
  color: var(--texto);
  box-shadow: var(--sombra-3);
}

dialog.modal::backdrop {
  background: rgba(6, 43, 38, 0.45);
  backdrop-filter: blur(2px);
}

dialog.modal--largo { width: min(1000px, calc(100vw - 2rem)); }

.modal__topo {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--borda);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal__topo h2 { flex: 1; font-size: 1.05rem; }

.modal__corpo {
  padding: 1.15rem;
  max-height: min(70vh, 640px);
  overflow-y: auto;
}

.modal__rodape {
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--borda);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: var(--surface-2);
}

/* --------------------------------------------------------------- outros -- */

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip {
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--borda-forte);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--texto-2);
  cursor: pointer;
}

.chip:hover { background: var(--surface-3); text-decoration: none; }
.chip[aria-pressed="true"], .chip.ativo {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}

.miniatura {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  object-fit: cover;
  border: 1px solid var(--borda);
  background: var(--surface-3);
  flex: 0 0 40px;
}

.miniatura--grande { width: 72px; height: 72px; flex-basis: 72px; }

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--fonte-num); }
.mudo { color: var(--texto-3); }
.forte { font-weight: 650; }
.pequeno { font-size: 0.8rem; }
.positivo { color: var(--verde); }
.negativo { color: var(--vermelho); }
.centro { text-align: center; }
.direita { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.oculto { display: none !important; }

.carregando {
  position: relative;
  pointer-events: none;
}
.carregando::after {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  border-radius: inherit;
}

.pulso { animation: pulso 0.45s ease; }
@keyframes pulso {
  0% { background-color: var(--brand-100); }
  100% { background-color: transparent; }
}

/* ---------------------------------------------------------------- login -- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(1100px 500px at 15% -10%, rgba(20, 133, 111, 0.16), transparent 60%),
    radial-gradient(900px 460px at 100% 105%, rgba(217, 155, 43, 0.14), transparent 60%),
    var(--canvas);
}

.login__cartao {
  width: min(410px, 100%);
  background: var(--surface);
  border: 1px solid var(--borda);
  border-radius: var(--r-lg);
  box-shadow: var(--sombra-2);
  padding: 1.85rem;
}

.login__marca {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

.login__marca .sidebar__logo { width: 40px; height: 40px; flex-basis: 40px; font-size: 1.05rem; }
.login__marca .sidebar__nome { font-size: 1.2rem; color: var(--texto); }
.login__marca .sidebar__sub { color: var(--texto-3); }

.login__rodape {
  margin-top: 1.35rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--borda);
  font-size: 0.78rem;
  color: var(--texto-3);
  text-align: center;
  line-height: 1.5;
}

.codigo-2fa {
  font-family: var(--fonte-num);
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 0.65rem;
}

.codigos-recuperacao {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  font-family: var(--fonte-num);
  font-size: 0.88rem;
  background: var(--surface-2);
  border: 1px solid var(--borda);
  border-radius: var(--r-sm);
  padding: 0.8rem;
}

/* ------------------------------------------------------------ responsivo -- */

@media (max-width: 1100px) {
  .grade--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grade--etapas { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--sombra-3);
  }
  .sidebar.aberta { transform: translateX(0); }
  .menu-botao { display: inline-flex; }
  .principal { padding: 1rem; }
  .topo { padding: 0.7rem 1rem; }
  .grade--2, .grade--3, .grade--4 { grid-template-columns: minmax(0, 1fr); }
  .detalhe-linha { grid-template-columns: 1fr auto 62px; }
  .codigos-recuperacao { grid-template-columns: 1fr; }
}

.veu {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 43, 38, 0.4);
  z-index: 55;
}
.veu.visivel { display: block; }

/* -------------------------------------------------------------- impressão */

@media print {
  .sidebar, .topo, .menu-botao, .botao, .veu { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .principal { padding: 0; max-width: none; }
  .cartao { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  details.sanfona > .sanfona__corpo { display: block !important; }
  a { color: inherit; text-decoration: none; }
}
