:root {
  color-scheme: dark;
  /* Paleta da marca IVB Capital: #5B574F (oliva), #2A2B2E (grafite), #A2A6A8 (cinza) */
  --olive: #5B574F;
  --olive-2: #6b665d;
  --grafite: #2A2B2E;
  --cinza: #A2A6A8;
  --bg: #1f2022;
  --surface: #2A2B2E;
  --surface-2: #323337;
  --surface-3: #3b3c40;
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #f5f5f4;
  --text-2: #d0d2d3;
  --muted: #9a9ea0;
  --gold: #c9ccce;       /* destaque (cinza claro da marca) */
  --gold-2: #e2e4e5;
  --gold-soft: rgba(91, 87, 79, 0.55); /* oliva translúcido */
  --good: #3fbf5f;
  --good-soft: rgba(63, 191, 95, 0.12);
  --warn: #fab219;
  --warn-soft: rgba(250, 178, 25, 0.12);
  --bad: #e66767;
  --bad-soft: rgba(230, 103, 103, 0.12);
  --grid: #3b3c40;
  --radius: 12px;
  --sidebar: 236px;
  font-family: "Exo 2", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--gold); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); }
.pos { color: var(--good); }

/* ---------- Marca ---------- */
.marca { display: block; }
.marca img { display: block; height: 42px; width: auto; }
.marca.grande img { height: 52px; margin: 0 auto; }
.sub-marca { color: var(--cinza); font-size: 12px; margin-top: 10px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- Botões / campos ---------- */
.btn { font: inherit; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); border-radius: 9px; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; }
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primario { background: var(--olive); color: #fff; border-color: var(--olive-2); font-weight: 600; }
.btn.primario:hover { background: var(--olive-2); }
.btn.perigo { color: var(--bad); border-color: rgba(230, 103, 103, 0.4); background: transparent; }
.btn.perigo:hover { background: var(--bad-soft); }
.btn.fantasma { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.fantasma:hover { background: var(--surface-2); }
.btn.icone { padding: 8px; }
.btn.largo { width: 100%; justify-content: center; }
.btn.pequeno { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.campo { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
input, select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 9px; padding: 8px 10px; min-height: 36px; }
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.erro-texto { color: var(--bad); margin: 0; font-size: 13px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; display: grid; gap: 16px; }
.login-card p { margin: 0 0 4px; text-align: center; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30; }
.sidebar .marca { padding: 0 10px; }
.sidebar .sub-marca { padding: 0 10px; margin-bottom: 22px; }
.menu { display: grid; gap: 2px; }
.menu a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--text-2); text-decoration: none; }
.menu a:hover { background: var(--surface-2); color: var(--text); }
.menu a.ativo { background: var(--olive); color: #fff; }
.sair { margin-top: auto; justify-content: flex-start; }
.principal { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topo { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: rgba(31, 32, 34, 0.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topo h1 { font-size: 19px; margin: 0; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-acoes { display: flex; align-items: center; gap: 10px; }
.seletor-data { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.menu-mobile { display: none; }
.conteudo { padding: 24px 28px 60px; max-width: 1500px; }
.veu { display: none; }


/* ---------- Blocos ---------- */
.secao { margin-bottom: 28px; }
.secao-titulo { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
.secao-titulo h2 { font-size: 15px; margin: 0; font-weight: 600; }
.secao-titulo .muted { font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 18px; }
.grade-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { padding: 16px 18px; }
.kpi .rotulo { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .valor { font-size: 24px; font-weight: 600; margin-top: 6px; white-space: nowrap; }
.kpi .delta { font-size: 12px; margin-top: 4px; color: var(--muted); }
.grade-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.fundo-card { padding: 16px 18px; display: grid; gap: 12px; align-content: start; }
.fundo-card header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.fundo-card h3 { font-size: 16px; margin: 0; font-weight: 600; }
.fundo-card h3 a { color: var(--text); text-decoration: none; }
.fundo-card h3 a:hover { color: var(--gold); }
.linha-barra { display: grid; gap: 5px; }
.linha-barra .topo-linha { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.linha-barra .nome { color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.barra i { display: block; height: 100%; background: var(--cinza); border-radius: 4px; }
.selo { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.selo svg { width: 13px; height: 13px; }
.selo.ok { background: var(--good-soft); color: var(--good); }
.selo.alerta { background: var(--warn-soft); color: var(--warn); }
.selo.ruim { background: var(--bad-soft); color: var(--bad); }
.selo.neutro { background: var(--surface-3); color: var(--text-2); }
.vazio { padding: 48px 20px; text-align: center; color: var(--muted); }
.vazio h2 { color: var(--text); font-size: 17px; margin: 0 0 6px; }

/* ---------- Tabelas ---------- */
.tabela-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); position: sticky; top: 0; }
th.ord { cursor: pointer; user-select: none; }
th.ord:hover { color: var(--text); }
th.ord[data-dir]::after { content: attr(data-dir); color: var(--gold); margin-left: 4px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
tr.clicavel { cursor: pointer; }
.fixa { position: sticky; left: 0; background: var(--surface); z-index: 1; }
th.fixa { background: var(--surface-2); z-index: 2; }
tbody tr:hover td.fixa { background: #2e2f33; }
tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border-2); border-bottom: 0; }
.txt-cel { color: var(--muted); font-style: italic; }

/* ---------- Tabela estilo planilha ---------- */
.planilha { font-size: 15px; }
.planilha th, .planilha td { padding: 12px 16px; border-right: 1px solid var(--border); }
.planilha thead th { font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); white-space: normal; min-width: 130px; line-height: 1.25; vertical-align: bottom; }
.planilha thead th a { color: var(--text); text-decoration: none; font-weight: 700; }
.planilha thead th a:hover { color: var(--gold); text-decoration: underline; }
.planilha th.rot { z-index: 1; font-size: 14px; font-weight: 600; color: var(--text-2); text-transform: none; letter-spacing: 0; background: var(--surface); position: sticky; left: 0; top: auto; min-width: 210px; }
.planilha tbody tr:nth-child(even) td, .planilha tbody tr:nth-child(even) th.rot { background: #2f3034; }
.planilha tr.destaque td, .planilha tr.destaque th.rot { color: var(--text); font-weight: 700; background: #47453f !important; }
.planilha tr.destaque th.rot { color: #fff; }
.planilha td { font-variant-numeric: tabular-nums; }
.unid { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.ancoras { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.ancoras a { font-size: 13px; color: var(--text-2); text-decoration: none; border: 1px solid var(--border-2); border-radius: 99px; padding: 5px 12px; }
.ancoras a:hover { color: var(--gold); border-color: var(--gold); }
.ancoras .muted { margin-left: auto; font-size: 13px; }
.secao { scroll-margin-top: 80px; }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--border-2); background: transparent; color: var(--text-2); border-radius: 99px; padding: 5px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.chip:hover { background: var(--surface-2); }
.chip.ativo { border-color: var(--gold); color: var(--text); background: var(--gold-soft); }
.chip .ponto { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Gráficos ---------- */
.grafico { position: relative; height: 340px; }
.grafico.baixo { height: 240px; }
.legenda { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---------- Upload ---------- */
.drop { display: block; border: 1.5px dashed var(--border-2); border-radius: var(--radius); padding: 40px 20px; text-align: center; background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.drop:hover, .drop.sobre { border-color: var(--gold); background: var(--gold-soft); }
.drop svg { width: 34px; height: 34px; color: var(--gold); }
.drop h3 { margin: 10px 0 4px; font-size: 16px; }
.lista-msg { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.lista-msg li { padding: 8px 12px; border-radius: 8px; font-size: 13px; display: flex; gap: 8px; }
.lista-msg li svg { width: 16px; height: 16px; margin-top: 1px; }
.lista-msg .aviso { background: var(--warn-soft); color: #f4d58a; }
.lista-msg .erro { background: var(--bad-soft); color: #f2a3a3; }
.resumo-upload { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.resumo-upload div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.resumo-upload b { display: block; font-size: 20px; }
.resumo-upload span { color: var(--muted); font-size: 12px; }
.acoes { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Detalhe do fundo ---------- */
.voltar { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-size: 13px; margin-bottom: 12px; }
.voltar:hover { color: var(--gold); }
.grade-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.lista-ind { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.lista-ind div { background: var(--surface); padding: 12px 14px; }
.lista-ind span { display: block; font-size: 12px; color: var(--muted); }
.lista-ind b { font-size: 16px; font-weight: 600; }

/* ---------- Modal / toast ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; padding: 22px; max-width: 420px; width: 100%; display: grid; gap: 14px; }
.modal h3 { margin: 0; font-size: 16px; }
.modal p { margin: 0; color: var(--text-2); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--border-2); padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); max-width: calc(100% - 32px); }
.toast.ok { border-color: rgba(63, 191, 95, 0.5); }
.toast.erro { border-color: rgba(230, 103, 103, 0.5); }
.carregando { padding: 60px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.aberta { transform: none; }
  .veu.aberto { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 25; }
  .principal { margin-left: 0; }
  .menu-mobile { display: inline-flex; }
  .topo { padding: 10px 16px; }
  .topo h1 { font-size: 16px; }
  .seletor-data span { display: none; }
  .conteudo { padding: 16px 16px 60px; }
  .grade-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .valor { font-size: 18px; }
  .kpi .delta { font-size: 11px; }
  .grade-cards, .grade-2 { grid-template-columns: 1fr; }
  .planilha { font-size: 14px; }
  .planilha th, .planilha td { padding: 10px 12px; }
  .planilha th.rot { min-width: 118px; max-width: 132px; white-space: normal; font-size: 12.5px; line-height: 1.25; }
  .planilha thead th { min-width: 118px; font-size: 12px; }
  .ancoras .muted { margin-left: 0; width: 100%; }
}
