:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e2e6ec;
  --text: #182230;
  --muted: #667085;
  --brand: #0b3d68;
  --brand-2: #1570ef;
  --accent: #12b76a;
  --danger: #d92d20;
  --warn: #b54708;
  --sidebar-bg: #0d1b2a;
  --sidebar-text: #c9d5e2;
  --sidebar-active: #1570ef;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.grow { flex: 1 1 220px; }
.pad { padding: .75rem 1rem; }

/* ---------------------------------------------------------------- layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 262px;
  flex: 0 0 262px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0 1rem;
  /* Presa na altura da tela: o menu rola dentro de .nav, e um menu longo nao
     empurra a pagina (o relatorio embedado ja e dimensionado para caber nela). */
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem 1.25rem; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-2), #0b3d68);
  color: #fff; font-weight: 700; font-size: .85rem; letter-spacing: .02em;
}
.brand-name {
  color: #fff; font-weight: 600; font-size: 1.05rem;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.nav { flex: 1; min-height: 0; overflow-y: auto; padding: 0 .75rem; }

/* Barra de rolagem no estilo da do Power BI embedado: fina, arredondada, sem
   setas nem trilho. A borda transparente com background-clip afasta o marcador
   da borda da sidebar sem precisar de elemento extra. */
.nav::-webkit-scrollbar { width: 12px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-button { display: none; }
.nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.18); background-clip: padding-box;
  border: 3px solid transparent; border-radius: 6px;
}
.nav::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,.32); }
.nav::-webkit-scrollbar-thumb:active { background-color: rgba(255,255,255,.42); }
/* So fora do Chromium: no Chrome 121+ scrollbar-color desliga o ::-webkit-scrollbar. */
@supports not selector(::-webkit-scrollbar) {
  .nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
}
.nav-group { margin-top: 1.1rem; }
.nav-group--admin { margin-top: 1.6rem; border-top: 1px solid rgba(255,255,255,.08); padding-top: 1rem; }
.nav-group-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: #7d8ea0; padding: 0 .75rem .35rem; display: flex; gap: .4rem; align-items: center;
}
.nav-link {
  display: block; padding: .5rem .75rem; border-radius: 7px;
  color: var(--sidebar-text); font-size: .9rem; text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--sidebar-active); color: #fff; font-weight: 500; }

.user-box { padding: .9rem 1.25rem 0; border-top: 1px solid rgba(255,255,255,.08); margin-top: .75rem; }
.user-name { color: #fff; font-size: .88rem; font-weight: 500; }
.user-mail { color: #7d8ea0; font-size: .75rem; margin-bottom: .4rem; word-break: break-all; }
.link-quiet { color: #9db2c8; font-size: .8rem; }

.content { flex: 1; min-width: 0; padding: 1.75rem 2rem 3rem; }

/* ------------------------------------------------------------------ head */
.page-head { margin-bottom: 1.5rem; }
.page-head--row { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 .3rem; font-size: 1.55rem; font-weight: 600; }
.page-head p { margin: 0; }
.crumb { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .25rem; }
.page-actions { display: flex; gap: .5rem; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .5rem .95rem; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand-2); color: #fff; font-size: .88rem; font-weight: 500;
  cursor: pointer; text-decoration: none; font-family: inherit;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; color: #fff; }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: #f4c7c3; }
.btn--danger:hover { background: #fef3f2; color: var(--danger); }
.btn--sm { padding: .32rem .6rem; font-size: .8rem; }
.btn--ms { width: 100%; background: #fff; color: #1b1b1b; border: 1px solid var(--border); padding: .7rem; }
.btn--ms:hover { background: #f7f7f7; color: #1b1b1b; }

/* ----------------------------------------------------------------- cards */
.card-group { margin-bottom: 2rem; }
.card-group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .7rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: .85rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.05rem; box-shadow: var(--shadow); color: var(--text);
  display: flex; flex-direction: column; gap: .8rem; min-height: 96px;
}
.card:hover { border-color: var(--brand-2); text-decoration: none; }
.card-title { font-weight: 600; }
.card-cta { color: var(--brand-2); font-size: .82rem; margin-top: auto; }

.empty {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.25rem; text-align: center; box-shadow: var(--shadow);
}
.empty h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
.empty .btn { margin-top: 1rem; }

/* ----------------------------------------------------------------- embed */
.embed-wrap {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.embed-container { width: 100%; height: calc(100vh - 210px); min-height: 480px; }
.embed-container iframe { border: 0; }

/* Pagina de relatorio: cabecalho de uma linha e a moldura preenchendo o resto
   da tela pelo flex, em vez de um desconto fixo que sobrava vazio embaixo. */
.content--dash {
  height: 100vh; display: flex; flex-direction: column;
  padding: .8rem 1.25rem 1rem;
}
.content--dash .dash-head { flex: 0 0 auto; align-items: center; margin-bottom: .6rem; }
.dash-title { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.dash-title .crumb { margin: 0; }
.dash-title h1 { margin: 0; font-size: 1.2rem; }
.dash-desc { margin: .1rem 0 0; font-size: .8rem; }
.content--dash .page-actions .btn { padding: .35rem .8rem; font-size: .82rem; }
.content--dash .page-actions { flex-wrap: wrap; align-items: center; gap: .25rem; }
.btn:disabled { opacity: .45; cursor: default; filter: none; }

/* Barra do relatorio so com icones; o nome da acao vai no title/aria-label. */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.btn-icon svg {
  width: 16px; height: 16px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.btn-icon:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-icon:focus-visible { outline: 2px solid rgba(21, 112, 239, .35); outline-offset: 1px; }
.btn-icon--danger:hover { background: #fef3f2; border-color: #fecdca; color: var(--danger); }
.btn-icon:disabled { opacity: .35; cursor: default; background: transparent; border-color: transparent; color: var(--muted); }
.btn-icon[hidden], .btn-icon svg[hidden] { display: none; }
.acoes-sep { width: 1px; height: 20px; background: var(--border); margin: 0 .3rem; }

.dialogo {
  width: min(400px, calc(100vw - 32px)); padding: 1.1rem 1.2rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialogo::backdrop { background: rgba(15, 23, 42, .35); }
.dialogo-texto { margin: 0 0 .7rem; font-size: .92rem; }
.dialogo input[hidden], .dialogo-acoes [hidden] { display: none; }
.dialogo-acoes { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* Filtros salvos: display flex sobrescreveria o hidden do HTML. */
.filtros { display: flex; gap: .25rem; align-items: center; }
.filtros[hidden] { display: none; }
.filtros select { margin-right: .15rem; }
.filtros select {
  width: auto; min-width: 11rem; max-width: 16rem; margin-top: 0;
  padding: .33rem .5rem; font-size: .82rem;
}
.filtro-suporte {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem;
}
.filtro-suporte-acoes { display: flex; gap: .5rem; }
.filtro-suporte-acoes .btn--ghost { color: var(--text); }
.content--dash .embed-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.content--dash .embed-container { flex: 1; height: auto; min-height: 320px; }
.embed-status {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--surface); color: var(--muted); font-size: .9rem; padding: 2rem; text-align: center;
}
.embed-status[hidden] { display: none; }
.embed-status.is-error { color: var(--danger); }
.embed-status pre {
  margin-top: .75rem; max-width: 640px; white-space: pre-wrap; text-align: left;
  font-size: .78rem; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: .75rem;
}

/* ----------------------------------------------------------------- forms */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1.1rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.panel summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
.panel[open] summary { margin-bottom: .9rem; }

label { display: block; font-size: .82rem; color: var(--muted); font-weight: 500; }
input[type=text], input[type=email], input[type=number], input[type=search], select {
  width: 100%; margin-top: .25rem; padding: .45rem .6rem;
  border: 1px solid var(--border); border-radius: 7px; background: #fff;
  font-family: inherit; font-size: .88rem; color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(21, 112, 239, .25); border-color: var(--brand-2); }

.form-row { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.form-row .btn { margin-bottom: 1px; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem; color: var(--text); white-space: nowrap; }
.check input { margin: 0; }
.hint { font-size: .78rem; color: var(--muted); margin: .6rem 0 0; }
.search { display: flex; gap: .5rem; align-items: center; }
.search input { width: 240px; margin-top: 0; }

.form-grid { display: flex; flex-direction: column; gap: 1.1rem; max-width: 940px; }
.fieldset {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.25rem; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1.1rem;
}
.fieldset legend { font-weight: 600; font-size: .9rem; padding: 0 .35rem; color: var(--text); }
.fieldset .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; }

.discovery { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.discovery-selects { display: flex; gap: .6rem; flex: 1 1 100%; }
.discovery-selects select { margin-top: 0; }

/* ---------------------------------------------------------------- tables */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: .7rem .9rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.table td { padding: .6rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-off td { opacity: .55; }
.table--nested { border-top: 1px solid var(--border); }
.row-actions { display: flex; gap: .35rem; align-items: center; }
.inline-form { display: inline; }

.inline-input { margin-top: 0; padding: .3rem .5rem; font-size: .86rem; }
.inline-input--title { max-width: 260px; font-weight: 600; }
.inline-input--icon { max-width: 70px; }
.inline-input--num { max-width: 70px; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chips--big .chip { font-size: .85rem; padding: .35rem .7rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--border); border-radius: 999px; padding: .2rem .55rem;
  font-size: .78rem; color: var(--text); background: var(--surface-2); cursor: pointer;
}
.chip:has(input:checked) { border-color: var(--brand-2); background: #eff8ff; color: var(--brand); }
.chip--static { cursor: default; }
.chip input { margin: 0; }

.tag { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.tag--warn { background: #fffaeb; color: var(--warn); border: 1px solid #fedf89; }

.menu-block {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 1.1rem; overflow: hidden;
}
.menu-block.is-off { opacity: .65; }
.menu-head { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; flex-wrap: wrap; }
.menu-icon { font-size: 1.1rem; }

/* ----------------------------------------------------------------- alert */
.alert {
  background: #eff8ff; border: 1px solid #b2ddff; color: #175cd3;
  padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .87rem;
}
.alert--error { background: #fef3f2; border-color: #fecdca; color: #b42318; }

/* ----------------------------------------------------------------- login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--sidebar-bg); }
.login-card {
  background: var(--surface); border-radius: 14px; padding: 2.25rem;
  width: min(400px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.35); text-align: center;
}
.brand--login { justify-content: center; padding: 0 0 .5rem; flex-wrap: wrap; }
.brand--login .brand-name { overflow: visible; white-space: normal; }
.brand--login .brand-name { color: var(--text); }
.login-sub { color: var(--muted); font-size: .88rem; margin: 0 0 1.5rem; }
.login-foot { color: var(--muted); font-size: .76rem; margin: 1.25rem 0 0; }
.error-code { font-size: 3rem; margin: 0 0 .5rem; color: var(--brand); }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; position: static; height: auto; }
  .content { padding: 1.25rem; }
  .fieldset { grid-template-columns: 1fr; }
  .embed-container { height: 70vh; }
  .content--dash { height: auto; display: block; }
  .content--dash .embed-container { height: 70vh; flex: none; }
}

/* O atributo hidden precisa vencer os display: flex/grid declarados acima. */
[hidden] { display: none !important; }

/* ------------------------------------------------------- white-label ---- */
/* Slot de tamanho fixo + object-fit: funciona para PNG, JPG e tambem para SVG
   que so declara viewBox (sem width/height, esse tipo de SVG nao tem tamanho
   intrinseco e `width: auto` viraria os 300x150 padrao do navegador). */
.brand-logo {
  display: block; flex: 0 0 auto;
  width: 150px; height: 34px;
  object-fit: contain; object-position: left center;
}
/* A logo e desenhada para o fundo escuro da barra lateral (normalmente em branco).
   No card de login, claro, ela some — entao repetimos a mesma placa escura. */
.brand-logo--login {
  width: 190px; height: 42px; object-position: center;
  padding: 10px 16px; box-sizing: content-box;
  background: var(--sidebar-bg); border-radius: var(--radius);
}

.brand-preview { display: flex; align-items: center; gap: 1rem; }
.brand-preview-box {
  display: grid; place-items: center;
  width: 230px; height: 64px; padding: 0 1rem; overflow: hidden;
  background: var(--sidebar-bg); border-radius: var(--radius);
}
/* SVG sem width/height intrinsecos estica se so limitarmos por max-*: fixamos a altura. */
.brand-preview-box img { width: 100%; height: 40px; object-fit: contain; }

input[type=file] {
  width: 100%; margin-top: .25rem; padding: .4rem .6rem;
  border: 1px dashed var(--border); border-radius: 7px; background: var(--surface-2);
  font-family: inherit; font-size: .85rem; color: var(--muted);
}

/* ------------------------------------------- barra lateral recolhivel ---- */
.sidebar { transition: width .18s ease, flex-basis .18s ease, padding .18s ease; }

.nav-toggle {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--sidebar-text);
}
.nav-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-toggle:focus-visible { outline: 2px solid var(--sidebar-active); outline-offset: 2px; }

/* Tres tracos desenhados em CSS: sem dependencia de fonte de icones. */
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block; width: 16px; height: 2px;
  background: currentColor; border-radius: 2px;
}
.nav-toggle-icon { position: relative; }
.nav-toggle-icon::before,
.nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
.nav-toggle-icon::before { top: -5px; }
.nav-toggle-icon::after { top: 5px; }

.nav-collapsed .sidebar {
  width: 52px; flex: 0 0 52px;
  padding-left: 0; padding-right: 0; overflow: hidden;
}
.nav-collapsed .sidebar .nav,
.nav-collapsed .sidebar .user-box,
.nav-collapsed .brand-mark,
.nav-collapsed .brand-logo,
.nav-collapsed .brand-name { display: none; }
.nav-collapsed .brand { justify-content: center; padding: 0; }

@media (max-width: 860px) {
  /* Em coluna, recolher vira uma faixa fina no topo com so o botao. */
  .nav-collapsed .sidebar { width: 100%; flex: none; padding: .6rem 0; }
  .nav-collapsed .brand { justify-content: flex-start; padding: 0 1rem; }
}
