/* =====================================================================
   Portal Energy - Folha de estilos
   ===================================================================== */

:root {
  --fundo:        #f4f6f9;
  --painel:       #ffffff;
  --borda:        #e3e8ef;
  --texto:        #1b2434;
  --texto-suave:  #667085;
  --lateral:      #101a2b;
  --lateral-alt:  #17233a;
  --lateral-txt:  #a7b4c8;
  --primaria:     #0f8f6b;
  --primaria-esc: #0b7355;
  --primaria-luz: #e6f5f0;
  --perigo:       #c0392b;
  --aviso:        #b7791f;
  --info:         #1d6fb8;
  --raio:         10px;
  --sombra:       0 1px 2px rgba(16,26,43,.06), 0 4px 14px rgba(16,26,43,.05);
  --lateral-larg: 252px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fundo);
  color: var(--texto);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
}

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

.ic { width: 19px; height: 19px; flex: 0 0 auto; }
.ic-sm { width: 15px; height: 15px; flex: 0 0 auto; }

/* ------------------------------------------------------------------ */
/* Autenticação                                                        */
/* ------------------------------------------------------------------ */
.ecra-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #101a2b 0%, #16324a 55%, #0f8f6b 160%);
}

.caixa-login {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 14px;
  padding: 34px 30px;
  box-shadow: 0 18px 50px rgba(0,0,0,.3);
}

.caixa-login .marca {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.caixa-login h1 { font-size: 20px; margin: 0; }
.caixa-login .sub { color: var(--texto-suave); font-size: 13px; margin: 0 0 22px; }

.logo-quadro {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--primaria);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}

/* ------------------------------------------------------------------ */
/* Formulários                                                         */
/* ------------------------------------------------------------------ */
.campo { margin-bottom: 15px; }
.campo label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #46536b;
  margin-bottom: 5px;
}

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  font: inherit;
  color: var(--texto);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primaria);
  box-shadow: 0 0 0 3px rgba(15,143,107,.14);
}

input[disabled], input[readonly] { background: #f6f8fa; color: var(--texto-suave); }

.codigo-2fa {
  text-align: center;
  letter-spacing: 10px;
  font-size: 26px;
  font-weight: 600;
  padding: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--raio);
  background: var(--primaria);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--primaria-esc); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--bloco { width: 100%; }
.btn--claro { background: #fff; color: var(--texto); border-color: var(--borda); }
.btn--claro:hover { background: #f3f5f8; }
.btn--perigo { background: var(--perigo); }
.btn--perigo:hover { background: #a13024; }
.btn--pequeno { padding: 6px 11px; font-size: 13px; }

/* ------------------------------------------------------------------ */
/* Avisos                                                              */
/* ------------------------------------------------------------------ */
.aviso {
  padding: 10px 13px;
  border-radius: var(--raio);
  margin-bottom: 14px;
  font-size: 13.5px;
  border: 1px solid;
}
.aviso--erro    { background: #fdeceb; border-color: #f5c6c2; color: #8e2a20; }
.aviso--ok      { background: #e8f6f1; border-color: #b9e2d5; color: #0b6d52; }
.aviso--info    { background: #eaf3fb; border-color: #c4dcf0; color: #17568e; }
.aviso--atencao { background: #fdf4e3; border-color: #f2ddb2; color: #8a6216; }

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

.lateral {
  width: var(--lateral-larg);
  flex: 0 0 var(--lateral-larg);
  background: var(--lateral);
  color: var(--lateral-txt);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .2s ease;
}

.lateral__marca {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 17px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff;
}
.lateral__marca strong { font-size: 15px; letter-spacing: .2px; }
.lateral__marca span { display: block; font-size: 11px; color: var(--lateral-txt); font-weight: 400; }

.lateral__menu { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }

.lateral__titulo {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: #6c7c94;
  padding: 16px 10px 7px;
  font-weight: 700;
}

.lateral a.item, .lateral button.item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 2px;
  border: 0;
  background: none;
  border-radius: 8px;
  color: var(--lateral-txt);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .13s, color .13s;
}
.lateral a.item:hover, .lateral button.item:hover { background: var(--lateral-alt); color: #fff; text-decoration: none; }
.lateral a.item.ativo { background: var(--primaria); color: #fff; font-weight: 600; }

.lateral .seta { margin-left: auto; transition: transform .18s; width: 14px; height: 14px; }
.lateral .grupo.aberto > button.item .seta { transform: rotate(90deg); }

.lateral .submenu { display: none; margin: 2px 0 6px 16px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.1); }
.lateral .grupo.aberto .submenu { display: block; }
.lateral .submenu a.item { padding: 7px 10px; font-size: 13.5px; }

.lateral__rodape { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); }

/* Conteúdo */
.principal {
  flex: 1;
  margin-left: var(--lateral-larg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topo {
  background: var(--painel);
  border-bottom: 1px solid var(--borda);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topo h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topo .direita { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primaria-luz);
  color: var(--primaria-esc);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px;
}

.utilizador-topo { text-align: right; line-height: 1.25; }
.utilizador-topo strong { font-size: 13px; display: block; }
.utilizador-topo span { font-size: 11.5px; color: var(--texto-suave); }

.conteudo { padding: 22px 24px 40px; flex: 1; }

.barra-personificacao {
  background: #8a6216;
  color: #fff;
  padding: 8px 24px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.barra-personificacao a { color: #fff; text-decoration: underline; font-weight: 600; }

.abrir-menu { display: none; background: none; border: 0; cursor: pointer; color: var(--texto); padding: 4px; }

/* ------------------------------------------------------------------ */
/* Cartões, grelhas e tabelas                                          */
/* ------------------------------------------------------------------ */
.cartao {
  background: var(--painel);
  border: 1px solid var(--borda);
  border-radius: 12px;
  box-shadow: var(--sombra);
  margin-bottom: 20px;
}
.cartao__cabeca {
  padding: 14px 18px;
  border-bottom: 1px solid var(--borda);
  display: flex;
  align-items: center;
  gap: 10px;
}
.cartao__cabeca h2 { font-size: 15px; margin: 0; font-weight: 650; }
.cartao__cabeca .direita { margin-left: auto; }
.cartao__corpo { padding: 18px; }

.grelha { display: grid; gap: 20px; }
.grelha--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grelha--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grelha--chat { grid-template-columns: minmax(0,1.55fr) minmax(0,1fr); align-items: start; }

.indicador { display: flex; align-items: center; gap: 13px; }
.indicador .simbolo {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--primaria-luz); color: var(--primaria-esc);
  display: flex; align-items: center; justify-content: center;
}
.indicador .valor { font-size: 21px; font-weight: 700; line-height: 1.1; }
.indicador .rotulo { font-size: 12.5px; color: var(--texto-suave); }

table.tabela { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tabela th, table.tabela td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--borda); }
table.tabela th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--texto-suave); background: #fafbfc; }
table.tabela tr:last-child td { border-bottom: 0; }
table.tabela tr:hover td { background: #fafbfc; }
.tabela-envolve { overflow-x: auto; }

.etiqueta {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: #eef1f5;
  color: #4a5568;
}
.etiqueta--ok { background: #e3f5ee; color: #0b6d52; }
.etiqueta--off { background: #fdeceb; color: #8e2a20; }
.etiqueta--admin { background: #eaf0fb; color: #274b8f; }

.vazio { text-align: center; color: var(--texto-suave); padding: 30px 12px; font-size: 13.5px; }

/* ------------------------------------------------------------------ */
/* Chat                                                                */
/* ------------------------------------------------------------------ */
.chat { display: flex; flex-direction: column; height: 460px; }
.chat__mensagens { flex: 1; overflow-y: auto; padding: 16px 18px; background: #fafbfc; }
.chat__form { display: flex; gap: 9px; padding: 12px; border-top: 1px solid var(--borda); background: #fff; }
.chat__form textarea { resize: none; height: 42px; max-height: 120px; }

.msg { display: flex; margin-bottom: 12px; }
.msg__balao {
  max-width: 76%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(16,26,43,.06);
}
.msg__meta { font-size: 10.5px; opacity: .75; margin-top: 4px; }
.msg--minha { justify-content: flex-end; }
.msg--minha .msg__balao { background: var(--primaria); color: #fff; border-bottom-right-radius: 3px; }
.msg--outro .msg__balao { background: #fff; border: 1px solid var(--borda); border-bottom-left-radius: 3px; }

.lista-conversas { max-height: 460px; overflow-y: auto; }
.lista-conversas a {
  display: block;
  padding: 11px 16px;
  border-bottom: 1px solid var(--borda);
  color: var(--texto);
}
.lista-conversas a:hover { background: #f7f9fb; text-decoration: none; }
.lista-conversas a.ativa { background: var(--primaria-luz); border-left: 3px solid var(--primaria); }
.lista-conversas .nome { font-weight: 600; font-size: 13.5px; }
.lista-conversas .previa { font-size: 12px; color: var(--texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contador {
  background: var(--perigo); color: #fff;
  border-radius: 999px; padding: 1px 7px;
  font-size: 11px; font-weight: 700;
}

/* ------------------------------------------------------------------ */
/* Diversos                                                            */
/* ------------------------------------------------------------------ */
.linha-info { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--borda); font-size: 13.5px; }
.linha-info:last-child { border-bottom: 0; }
.linha-info .rot { width: 150px; color: var(--texto-suave); flex: 0 0 auto; }

.caixa-permissoes { max-height: 320px; overflow-y: auto; border: 1px solid var(--borda); border-radius: var(--raio); padding: 10px 14px; }
.caixa-permissoes label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.caixa-permissoes .filho { margin-left: 22px; }

.acoes { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.sombreado { color: var(--texto-suave); font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ------------------------------------------------------------------ */
/* Responsivo                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 1000px) {
  .grelha--2, .grelha--3, .grelha--chat { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .lateral { transform: translateX(-100%); }
  body.menu-aberto .lateral { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .principal { margin-left: 0; }
  .abrir-menu { display: block; }
  .conteudo, .topo { padding-left: 16px; padding-right: 16px; }
  .utilizador-topo { display: none; }
}

/* ------------------------------------------------------------------ */
/* DBMap - mosaico de segmentação                                      */
/* ------------------------------------------------------------------ */
.filtros-dbmap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}
.filtros-dbmap label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: #46536b;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.mosaico-titulo {
  border: 1px solid var(--borda);
  border-bottom: 0;
  background: #fff;
  padding: 7px 10px;
  font-size: 13.5px;
}

.mosaico-grupos {
  display: flex;
  border: 1px solid var(--borda);
  border-bottom: 0;
  background: #fbfcfd;
}
.mosaico-grupos > div {
  padding: 5px 8px;
  font-size: 12px;
  color: var(--texto-suave);
  white-space: nowrap;
  overflow: hidden;
  border-right: 1px solid var(--borda);
}
.mosaico-grupos > div:last-child { border-right: 0; }
.mosaico-grupos .ponto {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}

.mosaico {
  display: flex;
  height: 460px;
  border: 1px solid var(--borda);
  overflow: hidden;
}
.mosaico__coluna {
  display: flex;
  flex-direction: column;
  border-right: 2px solid #fff;
  min-width: 0;
}
.mosaico__coluna:last-child { border-right: 0; }

.mosaico__bloco {
  display: block;
  min-height: 3px;
  position: relative;
  border-bottom: 2px solid #fff;
  padding: 7px 9px;
  overflow: hidden;
  text-decoration: none;
  transition: filter .12s, outline-color .12s;
  outline: 3px solid transparent;
  outline-offset: -3px;
}
.mosaico__bloco:last-child { border-bottom: 0; }
.mosaico__bloco:hover { filter: brightness(1.08); text-decoration: none; }
.mosaico__bloco.ativo { outline-color: #101a2b; }

.mosaico__rotulo {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
}
.mosaico__rotulo b { font-size: 13.5px; margin-right: 4px; }
.mosaico__valor { display: block; font-size: 12px; opacity: .92; }
.mosaico__rotulo--mini { font-size: 11px; line-height: 1; }
.mosaico__bloco { padding: 5px 8px; }

.chip-seg {
  display: inline-block;
  min-width: 30px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 780px) {
  .mosaico { height: 360px; }
  .mosaico__rotulo { font-size: 11.5px; }
  .mosaico__valor { font-size: 10.5px; }
}
