/* ============================================================
   Plataforma Perdas Técnicas — Daimon Engenharia
   Design System v5 — "Energy in Motion"

   Conceito: sidebar clara para integrar a logo transparente
   sem fundo. Riqueza visual vem do gradient mesh do fundo,
   hero card navy, sombras em camadas, e detalhes laranja.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

/* ============================================================
   GATING POR PAPEL (atributos setados em api.js applyRoleGating)
   FAIL-CLOSED: esconde por padrão até PROVAR o papel (data-* só é setado
   após o /me). Sem isso, itens internos piscavam visíveis/clicáveis para o
   cliente antes do gating e um clique gerava redirect 302 ("voltava sozinho").
   ============================================================ */
body:not([data-tipo="interno"]) .interno-only { display: none !important; }
body:not([data-papel="interno_admin"]) .admin-only { display: none !important; }
body:not([data-papel="cliente_gestor"]) .gestor-only { display: none !important; }
/* Controles que exigem permissão de ESCRITA na empresa ativa */
body[data-escrita="nao"] .escrita-empresa { display: none !important; }
/* Camada anti-flash (pré-pintura): o <html> recebe data-apresentacao="on" via
   script inline no <head> lendo o localStorage, ANTES do /me. Só oculta (nunca
   revela) — desync é auto-corrigido pelo applyRoleGating após o /me. */
html[data-apresentacao="on"] .interno-only,
html[data-apresentacao="on"] .admin-only,
html[data-apresentacao="on"] .gestor-only,
html[data-apresentacao="on"] .escrita-empresa { display: none !important; }

/* Chip de usuário (topbar): avatar + menu suspenso */
.user-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #FF9A4A, #F47920);
  color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
#user-menu {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 168px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 30px rgba(13,27,62,0.16);
  overflow: hidden; z-index: 300; padding: 4px;
}
.user-menu-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 9px 12px; border-radius: 7px; font-family: inherit; font-size: 13px;
  font-weight: 600; color: var(--navy-600); cursor: pointer;
}
.user-menu-item:hover { background: var(--orange-pale, #FFF8F2); color: var(--orange, #F47920); }
/* Item de "modo apresentação" ativo (visão do cliente) */
.user-menu-item.ativo { color: #1E50A8; background: #EAF1FB; }

/* Indicador DISCRETO de modo apresentação: pontinho no avatar do usuário.
   Só o apresentador, ciente da convenção, percebe. */
.user-avatar { position: relative; }
body[data-apresentacao="on"] .user-avatar::after {
  content: ""; position: absolute; top: -1px; right: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #1E50A8; border: 2px solid #fff;
}

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Orange — espectro inspirado na esfera da logo */
  --orange-50:   #FFF8F2;
  --orange-100:  #FFEDD9;
  --orange-200:  #FFD4A6;
  --orange-300:  #FFB870;
  --orange-400:  #FF9A4A;
  --orange-500:  #F47920;   /* primary */
  --orange-600:  #D96510;
  --orange-700:  #B5530A;

  /* Navy — espectro */
  --navy-50:     #F4F6FC;
  --navy-100:    #E5EAF7;
  --navy-200:    #C7D1E8;
  --navy-300:    #94A3C7;
  --navy-400:    #4E5D8B;
  --navy-500:    #1E2D5C;
  --navy-600:    #0D1B3E;   /* primary */
  --navy-700:    #0A1430;

  /* Aliases legados (compatibilidade) */
  --orange:        var(--orange-500);
  --orange-hover:  var(--orange-600);
  --orange-light:  var(--orange-400);
  --orange-pale:   var(--orange-50);
  --orange-muted:  rgba(244,121,32,0.10);
  --orange-glow:   rgba(244,121,32,0.30);
  --navy:          var(--navy-600);
  --navy-hover:    var(--navy-500);
  --navy-mid:      var(--navy-500);
  --navy-accent:   #2563EB;
  --navy-light:    var(--navy-50);
  --charcoal:      var(--navy-600);

  /* Surfaces */
  --surface-base:    #F4F7FC;
  --surface-card:    #FFFFFF;
  --surface-sunken:  #EEF2F9;
  --surface-sidebar: #FFFFFF;
  --bg-main:         var(--surface-base);
  --bg-card:         var(--surface-card);
  --bg-input:        #F8FAFC;

  /* Borders */
  --border:        #E5EAF1;
  --border-light:  #EFF3F8;

  /* Text */
  --text-main:     var(--navy-600);
  --text-primary:  var(--navy-600);
  --text-secondary:var(--navy-400);
  --text-muted:    #5E6A86;
  --text-faint:    #7C879E;

  /* Status */
  --green:    #10B981;
  --green-bg: #D1FAE5;
  --red:      #EF4444;
  --red-bg:   #FEE2E2;
  --yellow:   #F59E0B;
  --yellow-bg:#FEF3C7;
  --blue:     #3B82F6;
  --blue-bg:  #DBEAFE;
  --gray-bg:  #F1F5F9;

  /* Shadows — em camadas para profundidade real */
  --shadow-xs:     0 1px 2px rgba(13,27,62,0.04);
  --shadow-sm:     0 2px 6px rgba(13,27,62,0.06), 0 1px 2px rgba(13,27,62,0.04);
  --shadow:        0 6px 20px rgba(13,27,62,0.08), 0 2px 6px rgba(13,27,62,0.05);
  --shadow-md:     0 8px 24px rgba(13,27,62,0.10), 0 3px 8px rgba(13,27,62,0.05);
  --shadow-lg:     0 16px 40px rgba(13,27,62,0.14), 0 6px 12px rgba(13,27,62,0.06);
  --shadow-xl:     0 32px 64px rgba(13,27,62,0.18), 0 8px 16px rgba(13,27,62,0.08);
  --shadow-orange: 0 8px 24px rgba(244,121,32,0.30), 0 2px 6px rgba(244,121,32,0.20);
  --shadow-navy:   0 8px 24px rgba(13,27,62,0.30), 0 2px 6px rgba(13,27,62,0.20);
  --shadow-card:   var(--shadow-sm);

  /* Radii */
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  /* Layout */
  --sidebar-width: 252px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* Gradient mesh — composição de múltiplos radial gradients */
  background-color: var(--surface-base);
  background-image:
    radial-gradient(ellipse 900px 700px at 100% 0%, rgba(244,121,32,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 700px 500px at 0% 100%, rgba(13,27,62,0.08) 0%, transparent 55%),
    radial-gradient(ellipse 500px 400px at 50% 50%, rgba(99,102,241,0.04) 0%, transparent 60%);
  background-attachment: fixed;
}

/* ============================================================
   SIDEBAR — gradient cream-warm em sinergia com a esfera laranja
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;

  /* Gradient quente: cream no topo → peach pálido no fundo,
     com glow laranja no canto inferior-esquerdo ecoando a esfera da logo */
  background:
    radial-gradient(ellipse 320px 240px at 0% 100%, rgba(244,121,32,0.16) 0%, transparent 60%),
    radial-gradient(ellipse 420px 320px at 100% 0%, rgba(255,184,112,0.18) 0%, transparent 55%),
    linear-gradient(180deg, #FFFAF3 0%, #FFF4E8 50%, #FFEFE0 100%);

  box-shadow:
    1px 0 0 rgba(244,121,32,0.10),
    4px 0 32px rgba(13,27,62,0.06);
}

/* Detalhe laranja na borda direita */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: -1px; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg,
    transparent 0%,
    transparent 6%,
    var(--orange-300) 11%,
    var(--orange-500) 17%,
    var(--orange-300) 23%,
    transparent 30%,
    transparent 100%);
  z-index: 1;
  opacity: 0.85;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Zona de marca — logo sem qualquer card */
.sidebar-brand {
  padding: 24px 22px 20px;
  border-bottom: 1px solid rgba(244,121,32,0.12);
  flex-shrink: 0;
  position: relative;
}

/* Linha decorativa quente abaixo da marca */
.sidebar-brand::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 22px;
  width: 60px; height: 1px;
  background: linear-gradient(90deg, var(--orange-500), transparent);
}

.brand-logo-card {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.brand-logo-card img {
  height: 42px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

.brand-platform {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 0 2px;
}

.brand-platform-name {
  color: var(--navy-600);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.brand-platform-sub {
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Nav */
.nav-section {
  padding: 14px 0 8px;
  flex: 1;
}

.nav-section-label {
  color: var(--text-faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0 22px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  margin: 2px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.7);
  color: var(--navy-600);
  box-shadow: 0 1px 2px rgba(13,27,62,0.04);
}

/* Active = pílula laranja sólida com sombra — destaque máximo na cream */
.nav-item.active {
  background: linear-gradient(135deg, var(--orange-400) 0%, var(--orange-500) 60%, var(--orange-600) 100%);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(244,121,32,0.32), 0 2px 4px rgba(244,121,32,0.20);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: linear-gradient(180deg, var(--orange-300), var(--orange-600));
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 8px rgba(244,121,32,0.40);
}

.nav-item svg { flex-shrink: 0; }
.nav-item.active svg { color: #FFFFFF; }

/* Footer */
.sidebar-footer {
  padding: 14px 22px 18px;
  border-top: 1px solid rgba(244,121,32,0.10);
  flex-shrink: 0;
}

.sidebar-footer-text {
  color: var(--text-faint);
  font-size: 10px;
  text-align: center;
  line-height: 1.7;
  letter-spacing: 0.02em;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* Folga inferior: reserva espaço para o botão flutuante de sugestões nunca
     cobrir conteúdo no canto (última linha de tabelas, paginação, etc.).
     Com box-sizing:border-box + min-height:100vh, não cria scroll em páginas curtas. */
  padding-bottom: 96px;
  position: relative;
  /* min-width:0 evita que conteúdo largo (tabelas, gráficos) estique o
     flex item além da viewport — sem isso a topbar/seletor saem da tela.
     overflow-x:hidden contém qualquer estouro residual. */
  min-width: 0;
  overflow-x: hidden;
}

/* Topbar — fundo translúcido + glassmorphism */
.topbar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 var(--border-light), 0 4px 16px rgba(13,27,62,0.04);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-accent {
  width: 4px;
  height: 36px;
  background: linear-gradient(180deg, var(--orange-300) 0%, var(--orange-500) 50%, var(--orange-600) 100%);
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--orange-glow);
}

.topbar-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy-600);
  line-height: 1.2;
  letter-spacing: -0.4px;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.topbar-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  padding: 28px 32px;
  flex: 1;
  position: relative;
}

/* ============================================================
   KPI CARDS — primeiro é hero navy, demais brancos com acento
   ============================================================ */
.cards-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 24px;
}

.cards-grid-4 { grid-template-columns: repeat(4, 1fr); }
.cards-grid-3 { grid-template-columns: repeat(3, 1fr); }
.cards-grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Acento lateral laranja em todos cards (exceto hero) */
.card::after {
  content: '';
  position: absolute;
  left: 0; top: 22px; bottom: 22px;
  width: 3px;
  background: linear-gradient(180deg, var(--orange-300), var(--orange-500));
  border-radius: 0 3px 3px 0;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.card:hover::after { opacity: 1; }

/* HERO CARD — primeiro card é gradiente navy com orb laranja */
.cards-grid .card:first-child {
  background:
    radial-gradient(ellipse 200px 150px at 100% 0%, rgba(244,121,32,0.35) 0%, transparent 60%),
    linear-gradient(135deg, var(--navy-500) 0%, var(--navy-600) 50%, var(--navy-700) 100%);
  border: none;
  box-shadow: var(--shadow-navy);
  color: white;
}

.cards-grid .card:first-child::after { display: none; }

/* Orb decorativo no hero */
.cards-grid .card:first-child::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, var(--orange-500) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0.45;
  filter: blur(20px);
}

.cards-grid .card:first-child .card-title {
  color: rgba(255,255,255,0.7);
  position: relative; z-index: 1;
}

.cards-grid .card:first-child .metric-value {
  color: white;
  position: relative; z-index: 1;
}

.cards-grid .card:first-child .metric-unit {
  color: rgba(255,255,255,0.65);
  position: relative; z-index: 1;
}

.cards-grid .card:first-child:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(13,27,62,0.4), 0 4px 12px rgba(13,27,62,0.2);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

.card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--orange-100), var(--orange-50));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange-500);
  flex-shrink: 0;
}

.metric-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--navy-600);
  line-height: 1;
  letter-spacing: -0.8px;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.metric-value.large  { font-size: 36px; }
.metric-value.medium { font-size: 24px; }

.metric-unit {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 500;
}

/* ============================================================
   BADGES
   ============================================================ */
.metric-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.badge-green  { background: var(--green-bg);    color: #047857; }
.badge-red    { background: var(--red-bg);       color: #991B1B; }
.badge-yellow { background: var(--yellow-bg);    color: #92400E; }
.badge-blue   { background: var(--blue-bg);      color: #1D4ED8; }
.badge-orange { background: var(--orange-100);   color: var(--orange-700); }
.badge-gray   { background: var(--gray-bg);      color: var(--text-muted); }
.badge-navy   { background: var(--navy-100);     color: var(--navy-500); }
/* Violeta = "atípico com problema" (alinhado a CONV_COLORS_NORM em charts.js) */
.badge-violet { background: #EDE9FE;             color: #5B21B6; }

/* ============================================================
   CHART CARDS
   ============================================================ */
.chart-card {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px 26px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.25s ease;
}

.chart-card:hover {
  box-shadow: var(--shadow-md);
}

/* Linha laranja sutil no topo */
.chart-card::before {
  content: '';
  position: absolute;
  top: 0; left: 24px;
  width: 64px;
  height: 3px;
  background: linear-gradient(90deg, var(--orange-500) 0%, var(--orange-300) 100%);
  border-radius: 0 0 3px 3px;
}

.chart-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.chart-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--navy-600);
  letter-spacing: -0.2px;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.chart-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
  max-width: 500px;
  line-height: 1.55;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ============================================================
   UPLOAD AREA
   ============================================================ */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface-sunken);
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--orange-500);
  background: var(--orange-50);
}

.upload-icon { font-size: 36px; margin-bottom: 10px; }
.upload-text { font-size: 14px; color: var(--text-muted); line-height: 1.6; }
.upload-text strong { color: var(--orange-600); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--orange-400) 0%, var(--orange-500) 50%, var(--orange-600) 100%);
  color: #fff;
  box-shadow: var(--shadow-orange);
}
.btn-primary:hover {
  box-shadow: 0 12px 28px rgba(244,121,32,0.45), 0 3px 8px rgba(244,121,32,0.25);
  transform: translateY(-1.5px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: linear-gradient(135deg, var(--navy-500) 0%, var(--navy-600) 100%);
  color: #fff;
  box-shadow: var(--shadow-navy);
}
.btn-secondary:hover {
  box-shadow: 0 12px 28px rgba(13,27,62,0.4);
  transform: translateY(-1.5px);
}

.btn-outline {
  background: var(--surface-card);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover {
  background: var(--surface-sunken);
  border-color: var(--orange-300);
  color: var(--orange-600);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #FECACA;
}
.btn-danger:hover { background: #FECACA; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ============================================================
   METRIC CHIPS (multi-select de simulações no dashboard)
   ============================================================ */
.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.chip-row-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface-card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  font-family: inherit;
  white-space: nowrap;
}

.metric-chip:hover:not(.disabled):not(.fixed) {
  border-color: var(--orange-300);
  color: var(--navy-600);
}

.metric-chip.selected {
  background: linear-gradient(135deg, var(--orange-50), var(--orange-100));
  border-color: var(--orange-500);
  color: var(--orange-700);
  box-shadow: 0 2px 6px rgba(244,121,32,0.18);
}

.metric-chip.selected::before {
  content: '✓';
  font-weight: 800;
  color: var(--orange-600);
}

.metric-chip.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--surface-sunken);
}

.metric-chip.fixed {
  background: linear-gradient(135deg, var(--navy-50), var(--navy-100));
  border-color: var(--navy-mid);
  color: var(--navy-600);
  cursor: default;
}
.metric-chip.fixed::before { content: '◆'; color: var(--navy-mid); }

.chip-counter {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  font-weight: 500;
}

/* ============================================================
   HEALTH CARD (saúde da última simulação)
   ============================================================ */
.health-card {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 28px;
  align-items: center;
}

.health-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.health-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.health-indicator::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.health-indicator.health-ok    { background: var(--green-bg);  color: #047857; }
.health-indicator.health-ok::before    { background: var(--green); box-shadow: 0 0 8px rgba(16,185,129,0.4); }
.health-indicator.health-warn  { background: var(--yellow-bg); color: #92400E; }
.health-indicator.health-warn::before  { background: var(--yellow); box-shadow: 0 0 8px rgba(245,158,11,0.4); }
.health-indicator.health-bad   { background: var(--red-bg);    color: #991B1B; }
.health-indicator.health-bad::before   { background: var(--red); box-shadow: 0 0 8px rgba(239,68,68,0.4); }

.health-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.health-row {
  display: grid;
  grid-template-columns: 160px 48px 1fr 58px;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.health-row-label {
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.health-row-pct {
  font-weight: 700;
  color: var(--navy-600);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.health-row-bar {
  height: 6px;
  background: var(--surface-sunken);
  border-radius: 4px;
  overflow: hidden;
}

.health-row-bar > div {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.health-row-count {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .health-card { grid-template-columns: 1fr; }
}

/* ============================================================
   EMPRESA SELECTOR (topbar)
   ============================================================ */
.empresa-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 12px;
  background: var(--surface-card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-xs);
  color: var(--navy-600);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.empresa-pill:focus-within {
  border-color: var(--orange-500);
  box-shadow: 0 0 0 3px rgba(244,121,32,0.14);
}

.empresa-pill svg {
  color: var(--orange-500);
  flex-shrink: 0;
}

.empresa-pill select {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-600);
  outline: none;
  cursor: pointer;
  padding-right: 4px;
  font-family: inherit;
  min-width: 130px;
}

.empresa-add-btn {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--orange-50);
  color: var(--orange-600);
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}

.empresa-add-btn:hover {
  background: linear-gradient(135deg, var(--orange-400), var(--orange-500));
  color: white;
  box-shadow: 0 4px 10px var(--orange-glow);
}

/* Pílula de "vs RTP" usada em KPIs */
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}
.kpi-delta-better { background: var(--green-bg); color: #047857; }
.kpi-delta-worse  { background: var(--red-bg); color: #991B1B; }
.kpi-delta-equal  { background: var(--gray-bg); color: var(--text-muted); }

/* ============================================================
   FP TOGGLE
   ============================================================ */
.fp-toggle {
  display: flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border-light);
}

.fp-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.18s;
  font-family: inherit;
  border-radius: 6px;
}

.fp-btn:hover { color: var(--navy-500); }

.fp-btn.active {
  background: linear-gradient(135deg, var(--navy-500), var(--navy-600));
  color: #fff;
  box-shadow: 0 2px 6px rgba(13,27,62,0.25);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

/* Wrapper de rolagem horizontal para tabelas dentro de cards (sem borda própria,
   pois o card já fornece a moldura). Em telas menores a tabela rola em vez de
   espremer; a min-width fica na própria tabela. */
.table-scroll {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th {
  background: linear-gradient(to bottom, var(--surface-sunken), #E9EEF5);
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 13px;
}

table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background 0.15s; }
table.data-table tbody tr:hover td { background: var(--orange-50); }

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar select,
.filter-bar input,
select.filter-select,
input.filter-input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  background: var(--surface-card);
  color: var(--text-primary);
  outline: none;
  transition: all 0.15s;
  font-family: inherit;
  box-shadow: var(--shadow-xs);
}

.filter-bar select:focus,
.filter-bar input:focus {
  border-color: var(--orange-500);
  box-shadow: 0 0 0 3px rgba(244,121,32,0.14);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,62,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 460px;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--orange-300), var(--orange-500) 60%, var(--orange-600) 100%);
}

@keyframes modalIn {
  from { transform: scale(0.94) translateY(12px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-600);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  max-width: 360px;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.22s ease;
  border-left: 3px solid;
}

.toast-success { background: var(--green-bg);   color: #065F46; border-color: var(--green); }
.toast-error   { background: var(--red-bg);      color: #991B1B; border-color: var(--red); }
.toast-info    { background: var(--orange-50);   color: var(--orange-700); border-color: var(--orange-500); }

@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   WIDGET DE SUGESTÕES (botão flutuante + painel)
   z-index entre o conteúdo e os modais (200): o painel não cobre modais.
   ============================================================ */
.fab-wrap {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 150;
}
.fab-wrap[hidden] { display: none; }

.fab-sugestao {
  position: relative;          /* âncora do botão minimizar */
  width: 56px; height: 56px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  /* esfera laranja da logo Daimon */
  background: radial-gradient(circle at 32% 28%, var(--orange-300), var(--orange-500) 58%, var(--orange-600) 100%);
  box-shadow: var(--shadow-orange);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.fab-sugestao:hover { transform: translateY(-2px) scale(1.04); }
.fab-sugestao.ativo { transform: scale(0.96); }
.fab-sugestao:focus-visible { outline: 3px solid var(--orange-200); outline-offset: 2px; }

/* Botão "–" para minimizar (aparece ao passar o mouse / foco) */
.fab-min {
  position: absolute;
  top: -6px; right: -6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--navy-600);
  font-size: 16px; line-height: 1; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  opacity: 0; transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.fab-wrap:hover .fab-min,
.fab-wrap:focus-within .fab-min,
.fab-min:focus-visible { opacity: 1; transform: scale(1); }
.fab-min:hover { border-color: var(--orange-500); color: var(--orange-600); }

/* Aba discreta na borda direita (estado minimizado) — 1 clique restaura o FAB */
.fab-tab {
  position: fixed;
  right: 0; bottom: 88px;
  z-index: 150;
  width: 30px; height: 52px;
  border: none;
  border-radius: 12px 0 0 12px;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--orange-400), var(--orange-500) 60%, var(--orange-600));
  box-shadow: -3px 4px 14px rgba(244,121,32,0.32);
  transition: width 0.15s ease;
}
.fab-tab:hover { width: 38px; }
.fab-tab[hidden] { display: none; }
.fab-tab:focus-visible { outline: 3px solid var(--orange-200); outline-offset: 2px; }

.sugestao-panel {
  position: fixed;
  bottom: 92px; right: 24px;
  z-index: 150;
  width: 360px; max-width: calc(100vw - 32px);
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: sugIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
.sugestao-panel[hidden] { display: none; }
.sugestao-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--orange-300), var(--orange-500) 60%, var(--orange-600) 100%);
}
@keyframes sugIn {
  from { transform: translateY(16px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}
.sugestao-panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 18px 18px 12px;
}
.sugestao-panel-title {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-size: 15px; font-weight: 700; color: var(--navy-600);
}
.sugestao-panel-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.35; }
.sug-close {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.sug-close:hover { background: var(--surface-sunken); color: var(--navy-600); }
.sugestao-panel-body { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.sug-chips { display: flex; gap: 8px; }
.sug-chip {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.sug-chip:hover { border-color: var(--orange-300); }
.sug-chip.ativo {
  background: var(--orange-50);
  border-color: var(--orange-500);
  color: var(--orange-700);
}
#sug-titulo, #sug-msg {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: inherit; font-size: 13px;
}
#sug-titulo { font-weight: 600; }
#sug-msg { resize: vertical; min-height: 84px; }
#sug-titulo:focus, #sug-msg:focus { outline: none; border-color: var(--orange-500); }

/* Badge de não-lidas no item de menu "Sugestões" */
.nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--orange-500);
  color: #fff;
  font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,0.28); }
.nav-badge[hidden] { display: none; }

/* ============================================================
   LOADING
   ============================================================ */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border-light);
  border-top-color: var(--orange-500);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   STATUS CHIPS
   ============================================================ */
.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 42px; margin-bottom: 14px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--text-primary); }
.empty-state p  { font-size: 13px; line-height: 1.6; }

/* ============================================================
   MISC
   ============================================================ */
.section-divider {
  height: 1px;
  background: var(--border-light);
  margin: 20px 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1280px) {
  .cards-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .charts-row { grid-template-columns: 1fr; }
  .cards-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-brand,
  .nav-section-label,
  .nav-item span,
  .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-item::before { display: none; }
  .main-content { margin-left: 64px; }
  .cards-grid-4,
  .cards-grid-3 { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 18px; }
  .topbar { padding: 14px 18px; }
}

/* ============================================================
   AURORA FLOW — Visão Geral additions
   ============================================================ */

/* Fixed ambient background */
.aurora-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Ensure sidebar and main stay above bg */
.sidebar { z-index: 100; }
.main-content { position: relative; z-index: 1; }

/* Topbar as floating pill */
.topbar.topbar-pill {
  border-radius: 999px;
  margin: 16px 8px 24px;
  position: sticky;
  top: 16px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.75);
  box-shadow: 0 2px 8px rgba(13,27,62,.06), 0 1px 2px rgba(13,27,62,.04);
  padding: 12px 20px;
}

/* Hero KPI card */
.aurora-hero-card {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(120deg, #0D1B3E 0%, #1E2D5C 24%, #4A2E5C 50%, #B86A6A 72%, #E8866A 88%, #F47920 100%);
  box-shadow: 0 18px 48px rgba(13,27,62,.30);
  height: 220px;
  color: #fff;
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
}

/* Pill states used inside hero and KPI cards */
.aurora-pill-good {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16,185,129,0.22);
  color: #A6F0CE;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.aurora-pill-warn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(244,121,32,0.28);
  color: #FFD4A6;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

/* Dark background pill variants (for hero card) */
.aurora-hero-card .aurora-pill-good { color: #A6F0CE; }

/* Light pill for KPI cards (on white bg) */
.aurora-kpi .aurora-pill-good {
  background: rgba(16,185,129,0.12);
  color: #0E8763;
}
.aurora-kpi .aurora-pill-warn {
  background: rgba(244,121,32,0.12);
  color: var(--orange-700);
}

/* Dashboard grid rows */
.aurora-row-hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.aurora-kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.aurora-row-bottom {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

/* Aurora card surface */
.aurora-card {
  background: #fff;
  border-radius: 24px;
  border: 1px solid rgba(13,27,62,.04);
  box-shadow: 0 10px 28px rgba(13,27,62,.08), 0 3px 8px rgba(13,27,62,.04);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.aurora-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(13,27,62,.12), 0 4px 10px rgba(13,27,62,.06);
}

/* KPI card */
.aurora-kpi {
  padding: 20px;
  height: 130px;
  position: relative;
}

/* KPI label */
.aurora-kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

/* Cluster card at sidebar bottom */
.sidebar-cluster {
  position: relative;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.85), rgba(255,237,217,0.9));
  border: 1px solid rgba(244,121,32,0.18);
  overflow: hidden;
  margin-top: auto;
  flex-shrink: 0;
}

.sidebar-cluster::after {
  content: '';
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, rgba(244,121,32,0.55) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* Nav section header update */
.nav-section-label { padding: 20px 14px 8px; }

@media (max-width: 1280px) {
  .aurora-row-hero,
  .aurora-row-bottom { grid-template-columns: 1fr; }
  .aurora-kpi-row { grid-template-columns: 1fr 1fr; }
}

/* ── Tela Simulações ── */
.sim-row-top {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.sim-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 1280px) {
  .sim-row-top { grid-template-columns: 1fr; }
  .sim-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .sim-grid { grid-template-columns: 1fr; }
}

/* ── Tela Circuitos (Feeders) ── */
.feeders-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.feeder-row {
  display: grid;
  /* Circuito | Status | 10 colunas MWh iguais | % Final */
  grid-template-columns: 140px 110px repeat(10, 90px) 80px;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  min-width: 1370px;
}
.feeder-head {
  background: linear-gradient(180deg, #FAFBFE, #F4F7FC);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(13,27,62,0.05);
  line-height: 1.35;
}
.feeder-data {
  border-bottom: 1px solid rgba(13,27,62,0.04);
  transition: background 0.12s;
}
.feeder-data:hover { background: #FFF5EC; }
/* Células numéricas: preenchem a coluna inteira, texto à direita */
.feeder-row .num   { text-align: right; }
/* Célula de dado numérico padrão */
.feeder-row .num-cell {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  text-align: right;
}

