/*
 * Cards da página inicial — resumo por módulo.
 *
 * Carregado DEPOIS das folhas da página (vence o cascade sem !important).
 * Só propriedade visual: quem mostra e esconde bloco é o JS, por classe própria.
 */

#homeCards {
    --hc-bg: #131c2e;
    --hc-borda: rgba(148, 163, 184, 0.14);
    --hc-texto: #e2e8f0;
    --hc-fraco: #94a3b8;
    --hc-forte: #f8fafc;
    --hc-ok: #10b981;
    --hc-ok-claro: #6ee7b7;
    --hc-aviso: #f59e0b;
    --hc-aviso-claro: #fcd34d;
    --hc-erro: #ef4444;
    --hc-erro-claro: #fca5a5;
    --hc-indigo: #818cf8;
    --hc-neutro: #334155;
    display: block;
    margin-bottom: 1.25rem;
    /* A area de boas-vindas centraliza o texto; os cards sao alinhados a esquerda. */
    text-align: left;
}

/*
 * ⚠️ A area de boas-vindas (#welcomeArea) e um flex COLUMN com
 * justify-content: center e overflow: hidden. Com os cards, o conteudo passa da
 * altura disponivel e o TOPO fica cortado E INALCANCAVEL — o classico do flex
 * centrado: o excedente vaza para os dois lados e nao ha scroll que chegue la.
 * Medido: o card de Incidentes ficava em top -540px.
 * Com cards na tela, ela passa a crescer e quem rola e o .main-content, que ja
 * tem overflow: auto. A classe e posta pelo JS so quando ha card.
 */
.welcome-area.hc-ativo {
    justify-content: flex-start;
    flex: 0 0 auto;
    overflow: visible;
    /* A area nasceu para uma tela de boas-vindas curta: 2rem de margem + 3rem de
       padding. Com os cards ocupando a pagina, isso vira faixa vazia nos dois lados
       (80px de cada lado). Respiro menor = mais largura util, e o grid de icones
       acompanha, porque vivem no mesmo container. */
    margin: 1rem;
    padding: 1.25rem 1.5rem 1.5rem;
}
/* Com os cards na tela, o "Bem-vindo ao Manager Pro" vira repeticao ocupando o
   melhor espaco da pagina: quem diz o escopo agora e a barra "Visao geral · <empresa>". */
.welcome-area.hc-ativo #welcomeHero { display: none; }

/* align-items: center encolhe o filho ate o conteudo; os cards ocupam a largura. */
.welcome-area.hc-ativo #homeCards,
.welcome-area.hc-ativo #systemHealthSection { width: 100%; align-self: stretch; }

/* Barra fina acima dos cards: escopo e frescura, sem repetir o título da página */
.hc-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
    font-size: 0.8rem;
    color: var(--hc-fraco);
}
.hc-bar strong { color: var(--hc-texto); font-weight: 600; }
.hc-bar .hc-espaco { flex-grow: 1; }
.hc-bar button {
    height: 30px;
    padding: 0 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: var(--hc-bg);
    color: var(--hc-texto);
    font-size: 0.75rem;
    cursor: pointer;
}
.hc-bar button:hover { border-color: var(--hc-indigo); color: #fff; }

.hc-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
}

.hc-card {
    background: var(--hc-bg);
    border: 1px solid var(--hc-borda);
    border-radius: 14px;
    padding: 1.1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
}
.hc-card.hc-alerta { border-color: rgba(239, 68, 68, 0.38); }
.hc-card.hc-atencao { border-color: rgba(245, 158, 11, 0.38); }

.hc-s4 { grid-column: span 4; }
.hc-s5 { grid-column: span 5; }
.hc-s7 { grid-column: span 7; }
.hc-s8 { grid-column: span 8; }
.hc-s12 { grid-column: span 12; }

@media (max-width: 1400px) {
    .hc-s5, .hc-s7 { grid-column: span 6; }
}
@media (max-width: 1100px) {
    .hc-s4, .hc-s8 { grid-column: span 6; }
}
@media (max-width: 760px) {
    .hc-s4, .hc-s5, .hc-s7, .hc-s8 { grid-column: span 12; }
}

/* Cabeçalho do card */
.hc-head { display: flex; align-items: center; gap: 0.65rem; }
.hc-ico {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.hc-head h3 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1.2;
}
.hc-head .hc-sub { font-size: 0.72rem; color: var(--hc-fraco); }
.hc-head-txt { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.hc-abrir {
    font-size: 0.78rem;
    font-weight: 500;
    color: #a5b4fc;
    text-decoration: none;
    white-space: nowrap;
}
.hc-abrir:hover { color: #c7d2fe; text-decoration: underline; }

/* Selo de estado */
.hc-selo {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.hc-selo-erro { background: rgba(239, 68, 68, 0.16); color: var(--hc-erro-claro); }
.hc-selo-aviso { background: rgba(245, 158, 11, 0.16); color: var(--hc-aviso-claro); }
.hc-selo-ok { background: rgba(16, 185, 129, 0.14); color: var(--hc-ok-claro); }
.hc-selo-neutro { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; }
.hc-selo-indigo { background: rgba(129, 140, 248, 0.16); color: #c7d2fe; }

/* Número principal */
.hc-heroi { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.hc-heroi .hc-n {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--hc-forte);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.hc-heroi .hc-nd { color: var(--hc-fraco); }
.hc-heroi .hc-lbl { font-size: 0.82rem; color: var(--hc-fraco); font-variant-numeric: tabular-nums; }

/* Barras */
.hc-trilho {
    height: 6px;
    border-radius: 3px;
    background: rgba(148, 163, 184, 0.16);
    display: flex;
    overflow: hidden;
}
.hc-trilho > span { border-radius: 3px; }
.hc-pilha { height: 9px; border-radius: 5px; display: flex; gap: 2px; overflow: hidden; }

/* Listas por equipamento */
.hc-lista { display: flex; flex-direction: column; gap: 0.6rem; }
.hc-item { display: flex; flex-direction: column; gap: 5px; text-decoration: none; }
.hc-item:hover .hc-item-nome { color: #fff; text-decoration: underline; }
.hc-item-linha {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.78rem;
    min-width: 0;
}
.hc-item-nome {
    color: var(--hc-texto);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hc-item-sub { color: var(--hc-fraco); white-space: nowrap; }
.hc-item-val { margin-left: auto; color: #cbd5e1; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Legenda / contadores clicáveis */
.hc-legenda { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.76rem; }
.hc-legenda a, .hc-legenda span {
    display: flex; align-items: center; gap: 6px;
    color: #cbd5e1; text-decoration: none;
    font-variant-numeric: tabular-nums;
}
.hc-legenda a:hover { color: #fff; text-decoration: underline; }
.hc-ponto { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

.hc-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* Fila de incidentes */
.hc-inc { display: flex; flex-direction: column; gap: 0.45rem; }
.hc-inc-item {
    display: flex; gap: 0.6rem; align-items: flex-start;
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.06);
    text-decoration: none;
}
.hc-inc-item:hover { background: rgba(148, 163, 184, 0.11); }
.hc-inc-bola { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.hc-inc-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-grow: 1; }
.hc-inc-tit {
    font-size: 0.8rem; color: var(--hc-texto); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hc-inc-meta { font-size: 0.72rem; color: var(--hc-fraco); }
.hc-inc-tag { font-size: 0.68rem; font-weight: 600; color: var(--hc-erro-claro); white-space: nowrap; margin-top: 2px; }

/* Rodapé do card (frescura) */
.hc-rodape {
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.72rem;
    color: var(--hc-fraco);
}
.hc-rodape .hc-espaco { flex-grow: 1; }
.hc-rodape.hc-velho { color: var(--hc-aviso-claro); }

/* Estados */
.hc-vazio {
    font-size: 0.8rem;
    color: #cbd5e1;
    line-height: 1.5;
}
.hc-vazio a { color: #a5b4fc; }
.hc-aviso-box {
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    border: 1px dashed rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.07);
    font-size: 0.74rem;
    color: var(--hc-aviso-claro);
    line-height: 1.45;
}
.hc-erro-box {
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.08);
    font-size: 0.74rem;
    color: var(--hc-erro-claro);
}

/* Esqueleto de carregamento */
.hc-skel { background: rgba(148, 163, 184, 0.1); border-radius: 6px; display: block; }
.hc-skel-n { width: 120px; height: 30px; }
.hc-skel-l { width: 100%; height: 8px; }
.hc-skel-m { width: 70%; height: 8px; }

/* ============ Visão "todas as empresas" ============ */
.hc-totais {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
@media (max-width: 1200px) { .hc-totais { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .hc-totais { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.hc-tot {
    background: var(--hc-bg);
    border: 1px solid var(--hc-borda);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.hc-tot.hc-alerta { border-color: rgba(239, 68, 68, 0.35); }
.hc-tot-lbl { font-size: 0.72rem; color: var(--hc-fraco); }
.hc-tot-n { font-size: 1.35rem; font-weight: 700; color: var(--hc-forte); line-height: 1.1; font-variant-numeric: tabular-nums; }
.hc-tot-sub { font-size: 0.7rem; color: #cbd5e1; font-variant-numeric: tabular-nums; }

.hc-emp-head {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}
.hc-emp-head h3 { margin: 0; font-size: 0.92rem; font-weight: 600; color: #f1f5f9; }
.hc-emp-busca {
    height: 34px;
    min-width: 220px;
    padding: 0 0.7rem;
    border-radius: 9px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: #0b1220;
    color: var(--hc-texto);
    font-size: 0.8rem;
}

.hc-tab { display: flex; flex-direction: column; gap: 0.4rem; }
.hc-tab-cab, .hc-tab-lin {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) repeat(6, minmax(0, 1fr)) 110px;
    gap: 0.9rem;
    align-items: center;
}
.hc-tab-cab {
    padding: 0 0.85rem 0.5rem;
    border-bottom: 1px solid var(--hc-borda);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--hc-fraco);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.hc-tab-lin {
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.1);
    text-decoration: none;
    cursor: pointer;
}
.hc-tab-lin:hover { background: rgba(148, 163, 184, 0.09); }
.hc-tab-lin.hc-alerta { background: rgba(239, 68, 68, 0.06); border-color: rgba(239, 68, 68, 0.25); }
.hc-cel { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hc-cel-n { font-size: 0.82rem; color: var(--hc-texto); font-weight: 600; font-variant-numeric: tabular-nums; }
.hc-cel-s { font-size: 0.7rem; color: var(--hc-fraco); font-variant-numeric: tabular-nums; }
.hc-cel-nome { font-size: 0.9rem; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-cel-acao { font-size: 0.78rem; color: #a5b4fc; text-align: right; white-space: nowrap; }
.hc-sem-dado {
    grid-column: span 5;
    font-size: 0.76rem;
    color: var(--hc-fraco);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px dashed rgba(148, 163, 184, 0.25);
}

@media (max-width: 1200px) {
    .hc-tab-cab { display: none; }
    .hc-tab-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
    .hc-sem-dado { grid-column: span 2; }
    .hc-cel-acao { text-align: left; }
}

/* ------------------------------------------------------------------ */
/* Painel de personalização (quais cards aparecem e em que ordem)      */
/* ------------------------------------------------------------------ */

#homeCards .hc-prefs {
    background: var(--hc-bg);
    border: 1px solid var(--hc-borda);
    border-radius: 14px;
    padding: 0.9rem 1rem 0.8rem;
    margin-bottom: 1rem;
}

#homeCards .hc-prefs-cab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
    font-size: 0.82rem;
    color: var(--hc-texto);
}
#homeCards .hc-prefs-cab .hc-espaco { flex-grow: 1; }
#homeCards .hc-prefs-cab button {
    height: 28px;
    padding: 0 0.65rem;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: transparent;
    color: var(--hc-fraco);
    font-size: 0.73rem;
    cursor: pointer;
}
#homeCards .hc-prefs-cab button:hover { border-color: var(--hc-indigo); color: #fff; }

#homeCards .hc-pref-lista {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.4rem 0.75rem;
}

#homeCards .hc-pref-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 9px;
    font-size: 0.8rem;
    color: var(--hc-texto);
}
#homeCards .hc-pref-item .hc-espaco { flex-grow: 1; }
#homeCards .hc-pref-item label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    cursor: pointer;
    min-width: 0;
}
/* ⚠️ O <input> herda largura total das folhas de formulário do sistema; sem isto o
   checkbox vira uma barra e o rótulo desce, uma letra por linha (§103). */
#homeCards .hc-pref-item input[type="checkbox"] {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--hc-indigo);
}
#homeCards .hc-pref-item button {
    width: 26px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: transparent;
    color: var(--hc-fraco);
    font-size: 0.6rem;
    line-height: 1;
    cursor: pointer;
}
#homeCards .hc-pref-item button:hover:not(:disabled) { border-color: var(--hc-indigo); color: #fff; }
#homeCards .hc-pref-item button:disabled { opacity: 0.3; cursor: default; }
#homeCards .hc-pref-off { opacity: 0.55; }
#homeCards .hc-pref-off label span { text-decoration: line-through; }

#homeCards .hc-prefs-nota {
    margin: 0.7rem 0 0;
    font-size: 0.72rem;
    color: var(--hc-fraco);
    line-height: 1.45;
}

/* ============================================================================
   Camada da área de Colaboração na home (§109 do CLAUDE.md).

   ⚠️ Esta folha é a ÚLTIMA carregada pelo index.html — vence o index-page.css
   sem !important. Mexeu aqui, SUBIR o ?v= (§72).
   ⚠️ Os tokens abaixo ESPELHAM os --cb-* do collab.css: mudou a paleta lá,
   mudar aqui.
   ============================================================================ */

body {
    background:
        radial-gradient(1100px 500px at 110% -10%, rgba(99, 102, 241, 0.10), transparent 60%),
        radial-gradient(900px 480px at -10% 110%, rgba(34, 211, 238, 0.06), transparent 60%),
        #0b1120;
    /* ⚠️ um valor POR CAMADA: o computed devolve "fixed, fixed, fixed".
       Testar por inclusão, nunca por igualdade (§108). */
    background-attachment: fixed, fixed, fixed;
}

/* ─── Cabeçalho no molde ────────────────────────────────────────────────── */
/* ⚠️ O ícone em degradê vai na BARRA que já existe ("Visão geral · empresa"),
   nunca num cabeçalho novo: medido, um segundo cabeçalho custava +63px no
   desktop e +79px no celular para dizer o que a barra já diz — a duplicação
   que o §107 tinha acabado de tirar daqui. */
.hc-bar::before {
    content: '\f625';                    /* fa-gauge-high */
    font-family: 'Font Awesome 6 Free'; font-weight: 900;
    width: 26px; height: 26px; flex: 0 0 auto; margin-right: 0.15rem;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 0.78rem; color: #f8fafc;
    background: linear-gradient(135deg, #4338ca, #818cf8);
    box-shadow: 0 6px 14px -9px rgba(99, 102, 241, 0.8);
}

/* ⚠️ No celular o ícone SAI: a barra já quebra em três linhas lá, e medido ele
   custava +46px antes do primeiro card — identidade visual não vale empurrar o
   conteúdo numa tela onde ele já está apertado. */
@media (max-width: 767.98px) { .hc-bar::before { display: none; } }

/* o hero segue existindo para quem NÃO tem card nenhum (sem `.hc-ativo`) */
#welcomeHero { display: flex; align-items: center; gap: 0.85rem; margin-bottom: 1.1rem !important; }
#welcomeHero .hc-head-ico {
    width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #4338ca, #818cf8);
    box-shadow: 0 8px 18px -10px rgba(99, 102, 241, 0.75);
    color: #f8fafc; font-size: 1.05rem;
}
#welcomeHero h2 {
    margin: 0 !important; font-size: 1.32rem; font-weight: 700; letter-spacing: -0.01em;
    color: #f8fafc; line-height: 1.2;
}
#welcomeHero p {
    margin: 0.12rem 0 0 !important; color: #94a3b8; font-size: 0.86rem;
    /* ⚠️ `.lead` do Bootstrap é 1.25rem — grande demais para subtítulo aqui */
    line-height: 1.35;
}
/* ⚠️ `.text-secondary` do Bootstrap mede 4,02:1 sobre esta superfície. */
#welcomeHero .text-secondary, .system-health-section .text-secondary { color: #94a3b8 !important; }

@media (max-width: 767.98px) {
    #welcomeHero h2 { font-size: 1.14rem; }
    #welcomeHero .hc-head-ico { width: 36px; height: 36px; font-size: 0.92rem; }
}
