/* =============================================================
   ENIA Analytics — folha principal
   Densidade alta, bordas discretas, zero decoração.
   ============================================================= */

@import url('tokens.css');

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-graphite);
  background: var(--c-cloud);
  -webkit-font-smoothing: antialiased;
  /* Números tabulares em TODA a interface: colunas de valores alinham. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'cv05' 1;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-tight); color: var(--c-graphite); }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }

a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ───────────────────────── Shell ───────────────────────── */

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.shell[data-collapsed='true'] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ───────────────────────── Sidebar ───────────────────────── */

.sidebar {
  background: var(--c-navy);
  color: var(--c-on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  height: var(--header-h);
  padding: 0 var(--s-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
.sidebar__logo { width: 24px; height: 24px; flex-shrink: 0; }
.sidebar__name {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.shell[data-collapsed='true'] .sidebar__name,
.shell[data-collapsed='true'] .nav__label,
.shell[data-collapsed='true'] .nav__section,
.shell[data-collapsed='true'] .sidebar__footer-text { display: none; }

.nav { flex: 1; overflow-y: auto; padding: var(--s-3) 0; }
.nav__section {
  padding: var(--s-4) var(--s-4) var(--s-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-on-dark-2);
}
.nav__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 7px var(--s-4);
  color: var(--c-on-dark-2);
  font-size: var(--fs-base);
  border-left: 2px solid transparent;
  white-space: nowrap;
}
.nav__item:hover { background: var(--c-navy-raised); color: var(--c-on-dark); text-decoration: none; }
.nav__item[aria-current='page'] {
  background: var(--c-navy-raised);
  color: var(--c-white);
  border-left-color: var(--c-blue);
  font-weight: 500;
}
.nav__icon { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.75; }

.sidebar__footer {
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: var(--fs-xs);
  color: var(--c-on-dark-2);
  flex-shrink: 0;
}

/* ───────────────────────── Header ───────────────────────── */

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

.header {
  height: var(--header-h);
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-6);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header__title { flex: 1; min-width: 0; }
.breadcrumb { font-size: var(--fs-sm); color: var(--c-text-3); }
.breadcrumb a { color: var(--c-text-2); }
.header__page { font-size: var(--fs-md); font-weight: 600; }

.header__actions { display: flex; align-items: center; gap: var(--s-3); }

.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--c-blue-soft);
  color: var(--c-blue);
  display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: 600;
}

/* ───────────────────────── Conteúdo ───────────────────────── */

.content { padding: var(--s-6); max-width: 1560px; width: 100%; }

.toolbar {
  display: flex; align-items: center; gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.toolbar__spacer { flex: 1; }

.grid { display: grid; gap: var(--s-4); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1280px) { .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 980px)  {
  .grid--4, .grid--3, .grid--2 { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .content { padding: var(--s-4); }
}

/* ───────────────────────── Cards de indicador ───────────────────────── */

.panel {
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.panel__head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border-soft);
}
.panel__title { font-size: var(--fs-md); font-weight: 600; flex: 1; }
.panel__body { padding: var(--s-4); }

.kpi { padding: var(--s-4); }
.kpi__label {
  font-size: var(--fs-sm);
  color: var(--c-text-2);
  font-weight: 500;
  display: flex; align-items: center; gap: var(--s-2);
}
.kpi__value {
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--c-navy);
  margin-top: var(--s-2);
  line-height: 1.15;
}
.kpi__value--muted { color: var(--c-text-3); font-weight: 500; }
.kpi__foot {
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--c-text-3);
  display: flex; align-items: center; gap: var(--s-2);
}
.kpi__rule {
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
  color: var(--c-text-3);
  line-height: 1.4;
}

/* ───────────────────────── Selos de estado ───────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.badge--neutral { background: var(--c-border-soft); color: var(--c-text-2); }
.badge--success { background: var(--c-success-soft); color: var(--c-success); }
.badge--warning { background: var(--c-warning-soft); color: var(--c-warning); }
.badge--danger  { background: var(--c-danger-soft);  color: var(--c-danger); }
.badge--info    { background: var(--c-info-soft);    color: var(--c-info); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ───────────────────────── Formulários e botões ───────────────────────── */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--s-4); }
.label { font-size: var(--fs-sm); font-weight: 500; color: var(--c-graphite); }
.hint  { font-size: var(--fs-xs); color: var(--c-text-3); }

.input, .select {
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--c-graphite);
  background: var(--c-white);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 7px 10px;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--c-blue);
  box-shadow: 0 0 0 3px var(--c-blue-soft);
}
.select { appearance: none; padding-right: 28px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: var(--fs-base); font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn--primary   { background: var(--c-blue); color: var(--c-white); }
.btn--primary:hover { background: var(--c-blue-hover); }
.btn--secondary { background: var(--c-white); color: var(--c-graphite); border-color: var(--c-border); }
.btn--secondary:hover { background: var(--c-cloud); }
.btn--ghost     { background: transparent; color: var(--c-text-2); }
.btn--ghost:hover { background: var(--c-border-soft); color: var(--c-graphite); }
.btn--sm { padding: 4px 9px; font-size: var(--fs-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ───────────────────────── Tabelas ───────────────────────── */

.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.table th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-3);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
.table td {
  padding: 9px var(--s-3);
  border-bottom: 1px solid var(--c-border-soft);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--c-cloud); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ───────────────────────── Estados ───────────────────────── */

.empty {
  padding: var(--s-8) var(--s-4);
  text-align: center;
  color: var(--c-text-2);
}
.empty__title { font-weight: 600; color: var(--c-graphite); margin-bottom: 4px; }
.empty__text { font-size: var(--fs-sm); max-width: 440px; margin: 0 auto; }

.skeleton {
  background: var(--c-border-soft);
  border-radius: var(--r-sm);
  height: 1em;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.notice {
  display: flex; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid;
  font-size: var(--fs-base);
  margin-bottom: var(--s-4);
}
.notice--info    { background: var(--c-info-soft);    border-color: #B5E4F0; color: #0A5A70; }
.notice--warning { background: var(--c-warning-soft); border-color: #F0CFA0; color: #8A4D04; }
.notice--danger  { background: var(--c-danger-soft);  border-color: #F3B9B5; color: #991B1B; }

/* ───────────────────────── Gráficos ───────────────────────── */

.chart { width: 100%; height: 260px; }
.chart--tall { height: 320px; }

/* Barras horizontais simples — sem biblioteca para listas curtas. */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar__row { display: grid; grid-template-columns: 1fr 64px; gap: var(--s-3); align-items: center; }
.bar__label { font-size: var(--fs-sm); color: var(--c-graphite); }
.bar__track { height: 6px; background: var(--c-border-soft); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar__fill { height: 100%; background: var(--c-cyan); border-radius: 3px; }
.bar__value { font-size: var(--fs-sm); font-weight: 600; text-align: right; color: var(--c-graphite); }

/* ───────────────────────── Autenticação ───────────────────────── */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--c-navy);
  padding: var(--s-4);
}
.auth__card {
  width: 100%; max-width: 376px;
  background: var(--c-white);
  border-radius: var(--r-lg);
  padding: var(--s-8);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .28);
}
.auth__brand { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-6); }
.auth__logo { width: 30px; height: 30px; }
.auth__name { font-size: var(--fs-lg); font-weight: 600; }
.auth__title { font-size: var(--fs-lg); margin-bottom: var(--s-1); }
.auth__sub { font-size: var(--fs-sm); color: var(--c-text-2); margin-bottom: var(--s-6); }

/* ───────────────────────── Utilitários ───────────────────────── */

.u-muted { color: var(--c-text-2); }
.u-small { font-size: var(--fs-sm); }
.u-xs    { font-size: var(--fs-xs); }
.u-right { text-align: right; }
.u-nowrap { white-space: nowrap; }
.u-mb-0 { margin-bottom: 0; }
.u-mt-4 { margin-top: var(--s-4); }
.u-mt-6 { margin-top: var(--s-6); }
.u-flex { display: flex; align-items: center; gap: var(--s-2); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.btn--block { width: 100%; }
