:root {
  /* Identidade vinda do cabeçalho do relatório por e-mail (2026-08-27): um azul-carvão
     como base e UM laranja como marca. Antes o site liderava com âmbar (#f7a934,
     amarelado) e o laranja era só coadjuvante — a troca é o que dá a sobriedade do
     relatório. As cores do relatório são a fonte: app/reports.py (_INK e _BRAND). */
  --ink: #0f1720;            /* o mesmo _INK do relatório: bloco do cabeçalho */
  --brand: #f2701b;          /* o mesmo _BRAND: filete e a palavra ENERGY */

  --bg: #0f1720;
  --bg-grad-1: #16202c;
  --bg-grad-2: #0b1219;
  --surface: #172230;
  --surface-2: #1f2c3b;
  --surface-3: #283749;
  --text: #e9eef4;
  --muted: #8b98a8;
  /* No escuro o laranja da marca rende 6,4:1 contra o fundo — passa até em texto pequeno,
     então `--accent` é a marca sem concessão. */
  --accent: #f2701b;
  --accent-2: #ffa05a;       /* clareado da MESMA matiz, p/ realce sobre o laranja */
  --accent-soft: rgba(242, 112, 27, .15);
  --green: #2ecc71;
  --red: #e74c3c;
  --yellow: #f1c40f;
  --blue: #3498db;
  --violet: #9b59b6;
  --border: #28323e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
  --shadow-md: 0 6px 22px rgba(0,0,0,.30);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.42);
  /* Gradiente na MESMA família, sem amarelo: mantém o relevo dos botões sem trazer de
     volta o âmbar que a identidade nova deixou para trás. */
  --accent-grad: linear-gradient(135deg, #ff8a3d, #e2600f);
}

/* tema claro */
body.theme-light {
  --bg: #f4f6fa;
  --bg-grad-1: #eef2f8;
  --bg-grad-2: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #eff3f8;
  --surface-3: #e4eaf2;
  --text: #16202b;
  --muted: #5b6b7a;
  --border: #e2e8f0;
  /* Aqui a marca pura NÃO serve para texto: #f2701b sobre branco rende 2,95:1, abaixo do
     mínimo de 4,5:1. `--accent` vira o mesmo laranja escurecido (4,66:1) — mesma matiz,
     mesma leitura de identidade, legível. O âmbar antigo dava 1,97:1: já era ilegível.
     `--brand` continua puro para o filete e a marca, que são grafismo, não texto corrido. */
  --accent: #c1530b;
  --accent-2: #e2600f;
  --accent-soft: rgba(242, 112, 27, .12);
  --accent-grad: linear-gradient(135deg, #e2600f, #c1530b);
  --shadow-sm: 0 1px 2px rgba(20,30,45,.06);
  --shadow-md: 0 6px 20px rgba(20,30,45,.08);
  --shadow-lg: 0 18px 44px rgba(20,30,45,.12);
  --notice-warn-ink: #7a5600;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background:
    radial-gradient(1200px 600px at 85% -8%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 500px at -5% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;               /* nunca rolar horizontalmente */
}

a { color: inherit; text-decoration: none; }

/* blindagem responsiva: mídia nunca estoura; filhos de flex/grid podem encolher
   (min-width:auto padrão fazia gráficos/canvas empurrarem a largura no mobile) */
img, svg, video { max-width: 100%; }
canvas { max-width: 100%; }
.cards > *, .plant-grid > *, .detail-grid > *, .hero > *, .cmp-stats > *,
.impact-grid > *, .panel, .chart-box { min-width: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: rgba(247,169,52,.30); }

/* scrollbar discreta */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }

/* ---------- topbar / navegação ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  /* filete laranja no topo: é o elemento que assina o cabeçalho do relatório */
  border-top: 3px solid var(--brand);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em;
}
.brand .brand-text {
  /* Sem gradiente: no relatório a marca é texto chapado, caixa alta e espaçada — é daí
     que vem a sobriedade. Gradiente em texto pequeno ainda embaça a leitura. */
  color: var(--text);
  font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  font-size: .96rem;
}
.brand .brand-energy { color: var(--accent); }
.topbar nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-link {
  padding: 7px 13px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  color: var(--muted); transition: all .18s ease; white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.nav-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.topbar .user { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .85rem; }
.topbar .user .avatar {
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--accent-grad); color: #1a1200; font-weight: 800; font-size: .8rem;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer; font-size: 1rem; transition: all .18s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.badge { font-size: .7rem; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.badge-demo { background: var(--accent-grad); color: #1a1200; }

/* chip de papel/acesso */
.role-chip {
  font-size: .64rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
}
.role-chip.r-admin { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.role-chip.r-user { background: rgba(52,152,219,.16); color: var(--blue); }
.role-chip.r-collab { background: rgba(155,89,182,.18); color: var(--violet); }

.container { max-width: 1140px; margin: 0 auto; padding: 26px 24px 8px; animation: fadeUp .4s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.footer { text-align: center; color: var(--muted); padding: 28px 24px; font-size: .82rem; }
.footer .brand-text { color: var(--text); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.footer .brand-energy { color: var(--accent); }

/* ---------- cabeçalho de página ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.page-head .eyebrow { color: var(--accent); font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1 { font-size: 1.7rem; margin: 2px 0 0; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 1.12rem; margin: 30px 0 14px; color: var(--text); font-weight: 700; letter-spacing: -.01em; }
.section-sub { color: var(--muted); font-size: .88rem; margin: -8px 0 16px; }
/* O filete laranja marca começo de seção. Ele dependia de lembrar da classe `section` no
   h2, e metade das telas não lembrava: em Configurações, "Verificação em duas etapas" tinha
   o filete e "Aparência", logo acima, não — a mesma hierarquia com dois desenhos. Todo h2
   dentro de painel ganha o filete por ser o que é, sem depender de classe. */
h2.section::before,
.panel > h2:not(.with-ico)::before,
.panel > .panel-head > h2:not(.with-ico)::before {
  content: ""; display: inline-block; width: 4px; height: 1em; margin-right: 9px;
  vertical-align: -2px; border-radius: 3px; background: var(--accent-grad);
}

.notice {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  color: color-mix(in srgb, var(--accent) 78%, var(--text));
  padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: .9rem;
}
code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; font-size: .85em; }
.notice-error { background: rgba(231,76,60,.12); border-color: rgba(231,76,60,.45); color: #ff9b8f; }
.notice-success { background: rgba(46,204,113,.12); border-color: rgba(46,204,113,.45); color: #9be8bd; }
/* aviso: portal em espera ou relay parado — passa sozinho, então não é vermelho de erro */
.notice-warn { background: rgba(241,196,15,.12); border-color: rgba(241,196,15,.42); color: #f3d27a; }
body.theme-light .notice-warn { background: rgba(180,120,0,.10); border-color: rgba(180,120,0,.35);
                                color: var(--notice-warn-ink, #7a5600); }

/* ---------- cartões de resumo (KPI) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.card {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 88%, var(--bg)));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card-label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.card-value { font-size: 1.95rem; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; }
.card-sub { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.unit { font-size: .9rem; color: var(--muted); font-weight: 500; }
.card-icon {
  position: absolute; top: 14px; right: 14px; width: 38px; height: 38px;
  display: grid; place-items: center; border-radius: 11px; font-size: 1.25rem;
  background: var(--surface-2);
}
/* Tarja dos KPIs: UMA cor, a da marca, e discreta.
   Eram quatro cores (âmbar, verde, azul, violeta) que não codificavam nada — e duas delas
   eram praticamente as cores das séries 1 e 3 dos gráficos, o que fazia o leitor procurar
   uma relação entre o cartão azul e a usina azul. Cor sem significado ao lado de cor com
   significado é ruído que custa caro: gasta o único canal livre da tela. */
.card::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: .55; }
.card-sub .dot-online, .card-sub .dot-offline { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.card-sub .dot-online { background: var(--green); }
.card-sub .dot-offline { background: var(--red); }

/* Régua dos cartões de topo: o número ganha um "comparado com o quê".
   Mesma linguagem da barra de aproveitamento do cartão de potência, para a faixa
   de cartões ler como uma coisa só e não como três ilhas. */
.card-regua { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; }
.regua-trilho {
  flex: 1; height: 6px; border-radius: 99px; overflow: hidden;
  background: color-mix(in srgb, var(--border) 70%, transparent);
}
.regua-fill {
  height: 100%; border-radius: 99px; background: var(--accent);
  transition: width .6s cubic-bezier(.22,1,.36,1);
}
.regua-pct { font-size: .85rem; font-weight: 700; color: var(--muted); min-width: 34px; text-align: right; }

/* Média e projeção do mês: duas leituras pequenas lado a lado, sem competir
   com o número grande acima. */
.card-mes { display: flex; gap: 22px; margin: 12px 0 2px; }
.card-mes > div { display: flex; flex-direction: column; gap: 2px; }
.mes-rot { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mes-val { font-size: 1.02rem; font-weight: 700; }
.mes-val small { font-size: .75rem; font-weight: 500; color: var(--muted); }

@media (max-width: 520px) { .card-mes { gap: 16px; } }

/* ---------- ranking de geração ---------- */
.ranking { display: flex; flex-direction: column; margin-top: 16px; }
.rank-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.rank-item:last-child { border-bottom: none; }
.rank-top { display: grid; grid-template-columns: minmax(130px, 1.3fr) 2fr auto; align-items: center; gap: 12px; }
.rank-pos { color: var(--muted); font-size: .8rem; font-weight: 800; margin-right: 3px; }
.rank-name { display: flex; align-items: center; gap: 7px; font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.rank-bar { background: var(--surface-2); border-radius: 999px; height: 10px; overflow: hidden; }
.rank-fill { height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.4,0,.2,1); }
.rank-val { font-weight: 800; font-size: .9rem; text-align: right; white-space: nowrap; }
.rank-val small { display: block; color: var(--muted); font-weight: 500; font-size: .72rem; }
.rank-sub { color: var(--muted); font-size: .76rem; margin-top: 6px; padding-left: 2px; }
@media (max-width: 720px) {
  .rank-top { grid-template-columns: 1fr auto; }
  .rank-bar { display: none; }
}

.plant-card.accent-status-online  { border-left: 3px solid var(--green); }
.plant-card.accent-status-offline { border-left: 3px solid var(--red); }
.plant-card.accent-status-alert   { border-left: 3px solid var(--yellow); }
.plant-card.accent-status-unknown { border-left: 3px solid var(--border); }

/* ---------- alertas ---------- */
.alerts { margin-top: 8px; }
.alert {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 16px; margin-bottom: 10px; font-size: .9rem;
  box-shadow: var(--shadow-sm); transition: transform .15s ease, box-shadow .15s ease;
}
.alert:hover { transform: translateX(2px); box-shadow: var(--shadow-md); }
.alert-critical { border-left-color: var(--red); }
.alert-warning { border-left-color: var(--yellow); }
.alert-ok { border-left-color: var(--green); }
.alert-ic { font-size: 1.2rem; flex: 0 0 auto; line-height: 1; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 700; }
a.alert-title:hover { color: var(--accent); }
.alert-msg { color: var(--muted); font-size: .85rem; margin-top: 1px; }
.alert-sev { font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; flex: 0 0 auto; }
.sev-critical { background: rgba(231,76,60,.16); color: var(--red); }
.sev-warning { background: rgba(241,196,15,.18); color: #d4a800; }
/* compat: ponto antigo */
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.alert-critical .alert-dot { color: var(--red); }
.alert-warning .alert-dot { color: var(--yellow); }

/* ---------- onboarding (novos usuários) ---------- */
.onboarding { max-width: 760px; margin: 40px auto; }
.ob-hero { text-align: center; margin-bottom: 28px; }
.ob-logo { width: 64px; height: 64px; margin-bottom: 12px; color: var(--accent); }
.ob-hero h1 { font-size: 1.7rem; }
.ob-hero p { color: var(--muted); margin: 6px 0 0; }
.ob-steps { display: flex; flex-direction: column; gap: 14px; }
.ob-step {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm); transition: transform .2s ease, box-shadow .2s ease;
}
.ob-step:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ob-num {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 1.1rem; background: var(--accent-grad); color: #1a1200; box-shadow: 0 3px 10px rgba(242,112,27,.3);
}
.ob-step h3 { margin: 2px 0 4px; font-size: 1.05rem; }
.ob-step p { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.ob-portals { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.ob-portal { font-size: .76rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; }

/* ---------- grade de usinas (compacta ~10% menor) ---------- */
.plant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.plant-card {
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 90%, var(--bg)));
  border: 1px solid var(--border); border-radius: 13px;
  padding: 14px 15px; box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.plant-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
/* min-width: 0 porque .plant-card é grid: sem isto o cabeçalho é um item de grade com
   min-width "auto" e NÃO ENCOLHE abaixo do próprio conteúdo. Um nome de usina comprido
   (cliente com nome completo) empurrava a linha para fora do cartão — o texto, a barra de
   aproveitamento e a miniatura passavam por cima da borda e a pílula de status saía da
   tela. Com isto o nome corta com reticências e o resto fica dentro. */
.plant-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.plant-name { font-weight: 700; font-size: .95rem; }
.plant-power { font-size: 1.5rem; font-weight: 800; margin: 9px 0 5px; letter-spacing: -.02em; }
.plant-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; }
/* estimativa de geração (clima) no card */
.plant-est { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--border); font-size: .78rem; flex-wrap: wrap; }
.plant-est .pe-ico { font-size: 1rem; line-height: 1; }
.plant-est .pe-txt { color: var(--text); }
.plant-est .pe-txt strong { color: var(--accent); }
.plant-est .pe-cond { color: var(--muted); margin-left: auto; }
/* marca discreta de estimativa calibrada pelo histórico da usina (ver services._medir_fatores) */
.plant-est .pe-cal { color: var(--muted); font-size: .85em; vertical-align: super; margin-left: 1px; }

/* configuração de câmeras */
.cam-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
@media (max-width: 560px) { .cam-grid { grid-template-columns: 1fr; } }

/* janelinha de câmeras ao vivo no dashboard */
.cam-panel { margin-top: 12px; }
.cam-grid-live { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
@media (min-width: 900px) { .cam-grid-live { grid-template-columns: repeat(4, 1fr); } }
.cam-feed { position: relative; background: #000; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; aspect-ratio: 16 / 9; }
.cam-feed img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-feed .cam-name { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.55);
  color: #fff; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; backdrop-filter: blur(4px); }
.cam-feed .cam-name::before { content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 0 0 rgba(231,76,60,.6); animation: blink 2s infinite; }
.cam-feed .cam-err { position: absolute; inset: 0; display: none; place-items: center; text-align: center;
  color: var(--muted); font-size: .82rem; padding: 16px; }
.cam-feed.offline .cam-err { display: grid; }
.cam-feed.offline img { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .cam-feed .cam-name::before { animation: none; } }

/* ---------- barra de ferramentas das usinas ---------- */
.plants-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 16px; }
.plants-search {
  flex: 1; min-width: 180px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 13px; color: var(--text); font-size: .9rem;
  transition: border-color .18s, box-shadow .18s;
}
.plants-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plants-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.plants-sort {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; color: var(--text); font-size: .85rem; cursor: pointer;
}
.plants-empty { color: var(--muted); padding: 20px 0; }

/* card de usina enriquecido */
.plant-vendor {
  display: inline-block; margin-top: 7px; font-size: .66rem; font-weight: 700;
  letter-spacing: .02em; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px;
}
.plant-util { display: flex; align-items: center; gap: 9px; margin: 2px 0 10px; }
.plant-util-bar { flex: 1; height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.plant-util-fill { height: 100%; border-radius: 999px; background: var(--accent-grad); transition: width .6s cubic-bezier(.4,0,.2,1); }
.plant-util-pct { font-size: .72rem; font-weight: 800; color: var(--muted); min-width: 36px; text-align: right; }
/* A silhueta do dia no cartão: a curva de potência de HOJE, desenhada no servidor.
   Antes aqui havia um <canvas> com a forma da ÚLTIMA SEMANA, montado por JavaScript
   depois que a comparação terminava de carregar. Duas coisas estavam erradas: o cartão
   falava de hoje em todas as outras linhas (potência agora, kWh de hoje, estimativa de
   hoje) e só nesta falava da semana; e, por nascer de JavaScript, ele ficava em branco
   até a segunda requisição chegar — e em branco para sempre em conta sem histórico.
   A forma da semana não se perdeu: é o gráfico de comparação, logo abaixo, em tamanho
   de ler. Ver app/curvas.py. */
.plant-silhueta { position: relative; height: 34px; margin: 0 0 8px; }
.plant-silhueta svg { width: 100%; height: 100%; display: block; overflow: visible; }
.plant-silhueta .ps-linha { fill: none; stroke: var(--accent); stroke-width: 1.6;
  stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.plant-silhueta .ps-area { fill: url(#uhCurvaArea); }
/* Sem leitura hoje (usina offline, conta nova): um fio no chão. Diz "nada aconteceu"
   melhor que um espaço vazio — e mantém a altura, senão a grade de cartões desalinha. */
.plant-silhueta.ps-vazia::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 3px;
  border-top: 1px dashed var(--border);
}
/* O "agora" no cartão: o mesmo fio vertical da faixa do cabeçalho, em miniatura. */
.plant-silhueta .ps-agora { position: absolute; top: 2px; bottom: 3px; width: 0;
  border-left: 1px dashed color-mix(in srgb, var(--text) 28%, transparent); }

/* ---------- pills de status ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; text-transform: capitalize;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-online { color: var(--green); }
.status-pill.status-online { background: rgba(46,204,113,.15); }
.status-offline { color: var(--red); }
.status-pill.status-offline { background: rgba(231,76,60,.15); }
.status-pill.status-alert { background: rgba(241,196,15,.18); color: #d4a800; }
.status-pill.status-unknown { background: var(--surface-2); color: var(--muted); }

/* ---------- banner de aproveitamento (detalhe) ---------- */
.util-banner {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 11%, var(--surface)), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0;
  box-shadow: var(--shadow-sm);
}
.util-banner-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.util-banner-top span { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.util-banner-top strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.util-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 9px 0 6px; }
.util-prog { height: 100%; border-radius: 999px; background: var(--accent-grad); transition: width .8s cubic-bezier(.4,0,.2,1); }
.util-banner-sub { color: var(--muted); font-size: .84rem; }

/* ---------- página de detalhe ---------- */
.back { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .9rem; font-weight: 600; }
.back:hover { color: var(--accent); }
.detail-head { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.detail-head h1 { margin: 0; }
.muted { color: var(--muted); font-size: .9rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; margin-top: 8px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.panel h2 { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 15px; font-size: .82rem; font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: all .18s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.btn-primary {
  background: var(--accent-grad); color: #1a1200; border: none;
  box-shadow: 0 4px 14px rgba(242,112,27,.32);
}
.btn-primary:hover { filter: brightness(1.06); color: #1a1200; transform: translateY(-1px); }
.btn-sm { padding: 5px 11px; font-size: .78rem; }
.btn-danger:hover { border-color: var(--red); color: var(--red); }

/* ---------- estado vazio ---------- */
.empty-state {
  text-align: center; max-width: 480px; margin: 56px auto;
  padding: 44px 30px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.empty-state .empty-icon {
  font-size: 2rem; margin: 0 auto 14px; width: 72px; height: 72px; display: grid; place-items: center;
  border-radius: 20px; background: var(--accent-soft);
}
.empty-state h2 { margin: 0 0 8px; font-size: 1.2rem; }
.empty-state h2::before { content: none; }
.empty-state p { color: var(--muted); margin: 0 0 24px; line-height: 1.55; }

/* ---------- formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: .85rem; color: var(--muted); }
.field input, .field select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; font-size: 1rem;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-actions { margin-top: 4px; }

/* cartão de seleção */
.select-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: all .16s ease;
}
.select-card input { width: 18px; height: 18px; accent-color: var(--accent); }
.select-card:hover { border-color: var(--accent); background: var(--surface-3); }
.select-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* lista de usuários */
.user-list { list-style: none; padding: 0; margin: 8px 0 0; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-name { font-size: .92rem; font-weight: 600; }
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline; }
.role-badge { font-size: .66rem; padding: 2px 8px; border-radius: 999px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; margin-left: 4px; }
.role-badge.role-admin { background: var(--accent-soft); color: var(--accent); }
.role-badge.role-viewer { background: var(--surface-2); color: var(--muted); }
.kv { list-style: none; padding: 0; margin: 0; }
.kv li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.kv li:last-child { border-bottom: none; }
.kv span { color: var(--muted); }

/* ---------- editar dados das usinas ---------- */
/* seis colunas desde que entraram inversor (kW) e placas (kWp): as três numéricas são
   estreitas porque cabem 4-5 dígitos, e o nome fica com o espaço que sobra. */
.edit-row { display: grid; grid-template-columns: 100px 1fr 104px 104px 130px;
            gap: 9px; align-items: center; margin-bottom: 10px; }
@media (max-width: 900px) {
  /* empilha em duas faixas em vez de espremer seis colunas num celular */
  .edit-row { grid-template-columns: 1fr 1fr 1fr; }
  .edit-row .vlbl:nth-child(n+4) { display: none; }
}
.edit-row .vlbl { color: var(--muted); font-size: .82rem; }
.edit-head .vlbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.edit-row input {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 11px; font-size: .9rem; transition: border-color .18s, box-shadow .18s;
}
.edit-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
@media (max-width: 560px) {
  .edit-row { grid-template-columns: 1fr; gap: 5px; margin-bottom: 16px; }
  .edit-head { display: none; }
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.tab {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 15px; cursor: pointer; font-size: .85rem; font-weight: 600; transition: all .16s ease;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active { background: var(--accent-grad); color: #1a1200; border-color: transparent; font-weight: 700; box-shadow: 0 3px 10px rgba(242,112,27,.28); }
.tab-ghost { margin-left: auto; }
/* Seta do navegador de dia. Classe própria: usar .tab-ghost aqui herdava o
   `margin-left: auto` dela, que existe para empurrar Zoom/PNG para a direita na barra de
   abas — as setas ficavam espalhadas, longe do campo de data. */
.tab-seta { padding: 6px 12px; font-size: 1rem; line-height: 1.05; }
.tab:disabled { opacity: .42; cursor: not-allowed; }
.tab:disabled:hover { color: var(--muted); border-color: var(--border); }

/* ---------- login / auth ---------- */
.login-body {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 10px; padding: 20px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 34px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow-lg); animation: fadeUp .45s ease both;
}
.login-logo { width: 58px; height: 58px; margin: 0 auto 2px; }
.login-logo .uh-logo { width: 58px; height: 58px; }
.ob-logo .uh-logo { width: 100%; height: 100%; }
.login-brand { font-size: 1.5rem; font-weight: 800; text-align: center; letter-spacing: -.02em; }
.login-brand .brand-text { color: var(--text); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.login-brand .brand-energy { color: var(--accent); }
.login-sub { text-align: center; margin: -8px 0 6px; color: var(--muted); }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
.login-card input {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 13px; font-size: 1rem; transition: border-color .18s, box-shadow .18s;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-btn {
  background: var(--accent-grad); color: #1a1200; border: none; border-radius: 10px;
  padding: 12px; font-size: 1rem; font-weight: 800; cursor: pointer; margin-top: 4px;
  box-shadow: 0 4px 14px rgba(242,112,27,.32); transition: filter .18s, transform .18s;
}
.login-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.login-error { background: rgba(231,76,60,.12); border: 1px solid rgba(231,76,60,.4); color: #ff9b8f; padding: 10px 12px; border-radius: 10px; font-size: .88rem; text-align: center; }
.login-ok { background: rgba(46,204,113,.12); border: 1px solid rgba(46,204,113,.4); color: #9be8bd; padding: 10px 12px; border-radius: 10px; font-size: .88rem; text-align: center; }
.login-forgot { display: block; text-align: center; margin-top: 14px; color: var(--muted); font-size: .85rem; }
.login-forgot:hover { color: var(--accent); }
.login-link-btn { width: 100%; background: none; border: none; color: var(--muted); font-size: .82rem; cursor: pointer; text-decoration: underline; padding: 4px; }
.login-link-btn:hover { color: var(--accent); }
.login-register { text-align: center; margin-top: 16px; color: var(--muted); font-size: .88rem; }
.login-register a { color: var(--accent); font-weight: 700; }

/* indicador de passos (recuperação de senha) */
.auth-steps { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 2px 0 6px; }
.auth-step {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: .85rem; font-weight: 800; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); transition: all .2s ease;
}
.auth-step.active { background: var(--accent-grad); color: #1a1200; border-color: transparent; box-shadow: 0 3px 10px rgba(242,112,27,.3); }
.auth-step.done { background: rgba(46,204,113,.18); color: var(--green); border-color: transparent; }
.auth-step-line { width: 26px; height: 2px; background: var(--border); border-radius: 2px; }

/* ---------- seletor de intervalo / resumo ---------- */
.range-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; font-size: .85rem; color: var(--muted); }
.range-row input[type="date"], .range-row input[type="month"] { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: .85rem; }
/* `color-scheme` é o que faz o seletor NATIVO de data (calendário e ícone) sair escuro.
   Sem isto o campo fica certo e o calendário abre branco em cima do tema escuro. */
body:not(.theme-light) input[type="date"], body:not(.theme-light) input[type="month"] { color-scheme: dark; }

/* Campo de data em DD/MM/AAAA (ver app/static/data-br.js): o input nativo fica escondido
   como fonte do valor e o texto visível é o que o usuário lê e digita. */
.data-br { display: inline-flex; align-items: stretch; position: relative;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.data-br:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Especificidade alta de propósito: `.field input` (usada em /relatorios) é (0,2,0) e
   ganhava de `.data-br-txt` (0,1,0), devolvendo ao campo de texto borda, raio e anel de
   foco próprios — o controle aparecia como DUAS caixas, texto e calendário separados. */
.data-br input.data-br-txt { background: transparent; color: var(--text); border: 0; outline: 0;
  border-radius: 0; box-shadow: none; padding: 7px 4px 7px 10px; font-size: .85rem;
  width: 8.6em; font-variant-numeric: tabular-nums; }
.data-br input.data-br-txt:focus { border: 0; box-shadow: none; outline: 0; }
.data-br input.data-br-txt::placeholder { color: var(--muted); opacity: .7; }
.data-br .data-br-bt { display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-left: 1px solid var(--border); color: var(--muted);
  padding: 0 9px; cursor: pointer; }
.data-br .data-br-bt:hover { color: var(--accent); background: var(--surface-2); }
/* o nativo continua no DOM (form + .value em ISO), mas invisível e sem tomar o clique */
.data-br input.data-br-oculto { position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none; border: 0; box-shadow: none; padding: 0; margin: 0; }
/* sem showPicker(): o nativo reaparece, senão não haveria calendário nenhum */
.data-br input.data-br-visivel { background: transparent; color: var(--text); border: 0;
  border-left: 1px solid var(--border); padding: 7px 8px; font-size: .85rem; }
body:not(.theme-light) .data-br { color-scheme: dark; }
.gen-title { font-size: .85rem; margin: 0 0 10px; min-height: 1.1em; }
.range-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 4px 0 16px; }
.rs-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; display: flex; flex-direction: column; gap: 3px; }
.rs-card span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }
.rs-card strong { font-size: 1.2rem; letter-spacing: -.01em; }
.rs-card small { color: var(--muted); font-size: .75rem; }

/* ---------- gráficos ---------- */
.chart-box { position: relative; width: 100%; height: 300px; }
.chart-hint { font-size: .78rem; margin-top: 10px; opacity: .85; }

@media (max-width: 720px) {
  .topbar { padding: 11px 15px; }
  .container { padding: 18px 14px 8px; }
  .detail-grid { grid-template-columns: 1fr; }
  .chart-box { height: 240px; }
  .tab-ghost { margin-left: 0; }
  h1 { font-size: 1.4rem; }
  .card-value { font-size: 1.6rem; }
  .nav-link { padding: 6px 10px; font-size: .85rem; }
}

/* ---------- diagrama de fluxo (SVG legado) ---------- */
.energy-flow { width: 100%; max-width: 420px; margin: 4px auto 0; }
.ef-svg { width: 100%; height: auto; display: block; }
.ef-cable line { stroke: var(--border); stroke-width: 2.5; }
.ef-hub { fill: var(--accent); }
.ef-hub-ring { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .45; }
.ef-dot.ef-green { fill: var(--green); }
.ef-dot.ef-amber { fill: var(--accent); }
.ef-dot.ef-violet { fill: #9b59b6; }
.ef-node-bg { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; transition: stroke .3s; }
.ef-node-bg.on { stroke: var(--green); }
.ef-emoji { font-size: 26px; text-anchor: middle; dominant-baseline: middle; }
.ef-label { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.ef-val { fill: var(--text); font-size: 12px; font-weight: 600; text-anchor: middle; }
.ef-cable2 { stroke: rgba(255,255,255,.20); stroke-width: 2.5; }
body.theme-light .ef-cable2 { stroke: rgba(20,30,45,.18); }
body.theme-light .energy-flow ellipse[fill^="url"] { fill: rgba(20,30,45,.05); }
.ef2-label { fill: var(--muted); font-size: 13px; font-weight: 500; text-anchor: middle; }
.ef2-val { fill: var(--text); font-size: 16px; font-weight: 700; text-anchor: middle; }
.ef-badge { font-size: .74rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.ef-badge-online { color: #2ecc71; background: rgba(46,204,113,.14); }
.ef-badge-offline { color: var(--red); background: rgba(231,76,60,.14); }
.ef-badge-alert { color: var(--accent); background: rgba(245,166,35,.16); }
.ef-badge-unknown { color: var(--muted); background: var(--surface-2); }

/* ---------- fluxo via GIF + overlays ---------- */
/* ---------- diagrama de fluxo de energia (SVG, ao vivo) ---------- */
.eflow { display: block; width: 100%; max-width: 400px; margin: 10px auto 4px; height: auto; }

.eflow .ef-track { fill: none; stroke: var(--surface-3); stroke-width: 3.5; stroke-linecap: round; }
/* ramo sem energia: some quase por completo, para ler como "parado" e não como quebrado */
.eflow .ef-track.idle { stroke: var(--border); opacity: .55; }
.eflow .ef-flow {
  fill: none; stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 1 11; animation: efdash 1.1s linear infinite;
}
.ef-flow-solar { stroke: var(--accent); }
.ef-flow-load  { stroke: var(--blue); }
.ef-flow-grid  { stroke: var(--green); }
/* importando da rede: o fluxo corre no sentido inverso */
.eflow.is-import .ef-flow-grid { stroke: var(--violet); animation-direction: reverse; }
@keyframes efdash { to { stroke-dashoffset: -24; } }
@media (prefers-reduced-motion: reduce) {
  .eflow .ef-flow { animation: none; stroke-dasharray: none; opacity: .75; }
}

.eflow .ef-node circle { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; }
.eflow .ef-node use {
  fill: none; stroke: var(--muted); stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.ef-n-solar.on circle { stroke: var(--accent); fill: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.ef-n-solar.on use { stroke: var(--accent); }
.ef-n-load.on circle { stroke: var(--blue); fill: color-mix(in srgb, var(--blue) 14%, var(--surface-2)); }
.ef-n-load.on use { stroke: var(--blue); }
.ef-n-grid.on circle { stroke: var(--green); fill: color-mix(in srgb, var(--green) 14%, var(--surface-2)); }
.ef-n-grid.on use { stroke: var(--green); }
.eflow.is-import .ef-n-grid.on circle { stroke: var(--violet); fill: color-mix(in srgb, var(--violet) 14%, var(--surface-2)); }
.eflow.is-import .ef-n-grid.on use { stroke: var(--violet); }

.eflow .ef-val {
  fill: var(--text); font-size: 15px; font-weight: 800; text-anchor: middle;
  letter-spacing: -.02em;
}
.eflow .ef-val .ef-u { fill: var(--muted); font-size: 9.5px; font-weight: 500; }
.eflow .ef-cap {
  fill: var(--muted); font-size: 8.5px; font-weight: 700; text-anchor: middle;
  text-transform: uppercase; letter-spacing: .07em;
}
/* miolo do nó central (inversor): dá um ponto de convergência ao desenho */
.eflow .ef-hub-dot { fill: var(--muted); stroke: none; }
.eflow.is-export .ef-hub-dot { fill: var(--accent); }

/* legenda do balanço: transforma o espaço morto sob o diagrama em informação */
.ef-summary {
  margin: 0 0 14px; text-align: center; font-size: .85rem; color: var(--muted);
  line-height: 1.5;
}
.ef-summary strong { color: var(--text); font-weight: 700; }

.temp-hot { color: var(--red); }

/* ---------- marca / impacto ---------- */
/* A marca agora é SVG embutido (não <img>): pinta com currentColor, então basta dar a
   cor ao contexto. Sem caixa colorida — o quadrado ficou só no favicon, onde o fundo da
   aba é imprevisível. */
.uh-logo { width: 1.45em; height: 1.45em; display: block; flex: 0 0 auto; color: var(--accent); }
.brand .uh-logo { width: 1.35em; height: 1.35em; }
.impact-note { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; }
/* destaque (hero) do impacto */
.impact-hero {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, rgba(46,204,113,.16), var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--green) 25%, var(--border));
  border-radius: 14px; padding: 18px 22px; margin: 6px 0 16px;
}
.impact-hero-ic {
  flex: 0 0 auto; width: 52px; height: 52px; display: grid; place-items: center;
  border-radius: 15px; color: var(--green);
  background: color-mix(in srgb, var(--green) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 28%, transparent);
}
.impact-hero-val { font-size: 1.95rem; font-weight: 800; letter-spacing: -.02em; }
.impact-hero-val .unit { font-size: 1rem; font-weight: 600; color: var(--muted); }
.impact-hero-sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.impact-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.impact-grid-6 { grid-template-columns: repeat(6, 1fr); }
.impact-grid-3 { grid-template-columns: repeat(3, 1fr); }
/* três cartões cabem lado a lado até o celular estreito; abaixo disso empilham */
@media (max-width: 520px) { .impact-grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .impact-grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .impact-grid-6 { grid-template-columns: repeat(2, 1fr); } .impact-hero-val { font-size: 1.4rem; } .impact-hero-ic { width: 42px; height: 42px; border-radius: 12px; } }
.impact-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 12px; text-align: center; transition: transform .2s ease; }
.impact-item:hover { transform: translateY(-2px); }
.impact-icon {
  width: 38px; height: 38px; margin: 0 auto; display: grid; place-items: center;
  border-radius: 12px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  transition: color .2s ease, border-color .2s ease;
}
.impact-item:hover .impact-icon { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.impact-val { font-size: 1.35rem; font-weight: 800; margin-top: 10px; letter-spacing: -.02em; }
.impact-val .unit { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: 3px; }
.impact-lbl { color: var(--muted); font-size: .8rem; margin-top: 4px; }
@media (max-width: 520px) {
  .impact-grid { gap: 8px; }
  .impact-icon { width: 30px; height: 30px; border-radius: 10px; }
  .impact-val { font-size: 1.05rem; margin-top: 6px; }
  .impact-lbl { font-size: .68rem; }
}

/* ---------- hero do dashboard ---------- */
.hero {
  /* `block` e não `flex`: o cabeçalho passou a ter DUAS faixas — a linha de cima
     (saudação, data, estado da frota) e, embaixo, a forma do dia, que precisa da
     largura inteira para ser um gráfico e não um risco. */
  display: block;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px;
  margin-bottom: 22px; box-shadow: var(--shadow-sm);
  overflow: hidden;      /* o brilho do ponto do "agora" não vaza pela borda */
}
.hero-topo { display: flex; align-items: center; justify-content: space-between;
             gap: 16px; flex-wrap: wrap; }
.hero .hero-greeting { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
/* só a 1ª letra maiúscula: `capitalize` virava "Segunda-Feira, 24 De Agosto De 2026" */
.hero .hero-date { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.hero .hero-date::first-letter { text-transform: uppercase; }
.hero-status { display: flex; gap: 10px; flex-wrap: wrap; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .85rem; font-weight: 600;
}
.status-chip .sc-dot { width: 9px; height: 9px; border-radius: 50%; }
.status-chip b { font-weight: 800; }
.sc-online .sc-dot { background: var(--green); }
.sc-offline .sc-dot { background: var(--red); }
.sc-alert .sc-dot { background: var(--yellow); }

/* ---------- a forma do dia (faixa do cabeçalho) ----------
   A curva de geração da FROTA hoje, desenhada no servidor (app/curvas.py). Responde à
   pergunta que nenhum número responde sozinho: 12 kW às 9h são um dia excelente ou uma
   usina que acordou tarde? A curva cheia de manhã e mordida ao meio-dia é nuvem; a que
   só começa às 10h é defeito.

   A trilha da janela solar (`.sunwin-track`) continua logo abaixo e virou o EIXO da
   curva: o ponto do "agora" nela fica na mesma vertical do ponto do "agora" no traço.
   Duas leituras do mesmo instante, uma em cima da outra. */
.dia { margin-top: 18px; }
.dia-cab { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap;
           font-size: .7rem; font-weight: 700; letter-spacing: .06em;
           text-transform: uppercase; color: var(--muted); }
/* `margin-right:auto` empurra o estado do dia ("3h31 de sol") para a direita e mantém
   a legenda do pico colada no rótulo, à esquerda. Sem isto os três itens se espalhavam
   em distâncias iguais e a legenda flutuava sozinha no meio da faixa. */
.dia-pico { text-transform: none; letter-spacing: 0; font-size: .78rem; font-weight: 500;
            font-variant-numeric: tabular-nums; margin-right: auto; }
.dia-pico b { color: var(--text); font-weight: 700; }
.dia-tela { position: relative; height: 112px; margin: 10px 0 2px; }
.dia-tela svg { width: 100%; height: 100%; display: block; }
.dia-area { fill: url(#uhCurvaArea); }
.dia-linha { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round;
             stroke-linecap: round; vector-effect: non-scaling-stroke;
             filter: drop-shadow(0 2px 10px color-mix(in srgb, var(--accent) 45%, transparent)); }
/* Linhas de hora cheia: presentes para orientar, fracas para não disputar com o traço. */
.dia-grade { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .7; }
.dia-agora { position: absolute; top: 0; bottom: 0; width: 0;
             border-left: 1px dashed color-mix(in srgb, var(--text) 32%, transparent); }
.dia-ponto, .dia-pico-marca { position: absolute; border-radius: 50%;
                              transform: translate(-50%, -50%); }
/* Onde a frota está NESTE minuto. É o único elemento que brilha na tela inteira — e é
   de propósito: é para ele que o olho deve ir primeiro. */
.dia-ponto { width: 11px; height: 11px; background: var(--accent);
             box-shadow: 0 0 0 3px color-mix(in srgb, var(--surface) 70%, transparent),
                         0 0 18px color-mix(in srgb, var(--accent) 75%, transparent); }
/* O pico do dia: anel vazado, não bolinha cheia. Forma diferente do "agora" porque as
   duas marcas convivem no mesmo traço, e distinguir por cor só serve para quem vê cor. */
.dia-pico-marca { width: 9px; height: 9px; background: transparent;
                  border: 2px solid color-mix(in srgb, var(--text) 55%, transparent); }
/* ---- a lupa: ler o valor de um minuto qualquer ----
   Nasce escondida e só aparece com o ponteiro em cima (`.lupa-ativa`), senão a faixa
   chegaria à tela já riscada. `cursor: crosshair` é o convite: sem ele ninguém descobre
   que a faixa responde — foi exatamente o que aconteceu na primeira versão, que era
   bonita e parecia um desenho. */
.dia-tela { cursor: crosshair; }
.dia-lupa-linha, .dia-lupa-ponto, .dia-lupa-rot {
  position: absolute; opacity: 0; transition: opacity .12s ease; pointer-events: none;
}
.dia-tela.lupa-ativa .dia-lupa-linha,
.dia-tela.lupa-ativa .dia-lupa-ponto,
.dia-tela.lupa-ativa .dia-lupa-rot { opacity: 1; }
.dia-lupa-linha { top: 0; bottom: 0; width: 0;
                  border-left: 1px solid color-mix(in srgb, var(--text) 45%, transparent); }
.dia-lupa-ponto { width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%, -50%);
                  background: var(--text); box-shadow: 0 0 0 3px var(--surface); }
.dia-lupa-rot {
  top: -2px; transform: translateX(-50%);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 3px 9px;
  font-size: .76rem; font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums; box-shadow: var(--shadow-sm);
}
/* Com a lupa ligada, as marcas fixas saem de cena: três bolinhas na mesma faixa viram
   confusão, e quem está lendo um minuto específico não está olhando para o pico. */
.dia-tela.lupa-ativa .dia-ponto,
.dia-tela.lupa-ativa .dia-pico-marca,
.dia-tela.lupa-ativa .dia-agora { opacity: .18; transition: opacity .12s ease; }
@media (prefers-reduced-motion: reduce) {
  .dia-lupa-linha, .dia-lupa-ponto, .dia-lupa-rot { transition: none; }
}

.dia .sunwin-track { margin: 0 0 5px; }
@media (max-width: 760px) {
  .dia-tela { height: 78px; }
  .dia { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) { .dia-ponto { box-shadow: 0 0 0 3px var(--surface); } }

/* ---------- comparação entre usinas ---------- */
.cmp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 6px 0 16px; }
.cmp-stat {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px;
  display: flex; align-items: center; gap: 12px;
}
.cmp-stat .cmp-ic { font-size: 1.5rem; line-height: 1; }
.cmp-stat .cmp-k { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.cmp-stat .cmp-v { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; }
.cmp-stat .cmp-v small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); }
.cmp-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.cmp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.cmp-chip {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 13px; cursor: pointer; font-size: .82rem; font-weight: 600; transition: all .16s ease;
}
.cmp-chip:hover { color: var(--text); border-color: var(--accent); }
.cmp-chip.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.rank-medal { font-size: 1rem; margin-right: 2px; }
@media (max-width: 620px) {
  .cmp-stats { grid-template-columns: 1fr; }
}

/* entrada escalonada dos cards */
.cards .card, .plant-grid > * { animation: fadeUp .5s ease both; }
.cards .card:nth-child(2), .plant-grid > *:nth-child(2) { animation-delay: .05s; }
.cards .card:nth-child(3), .plant-grid > *:nth-child(3) { animation-delay: .10s; }
.cards .card:nth-child(4), .plant-grid > *:nth-child(4) { animation-delay: .15s; }
.plant-grid > *:nth-child(5) { animation-delay: .20s; }
.plant-grid > *:nth-child(6) { animation-delay: .25s; }
.plant-grid > *:nth-child(7) { animation-delay: .30s; }
.plant-grid > *:nth-child(n+8) { animation-delay: .35s; }

/* gráfico em tela cheia */
.chart-box:fullscreen { height: 100vh; width: 100vw; background: var(--bg); padding: 28px; }

/* ---------- Analytics (telemetria dos inversores) ---------- */
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.an-card .plant-vendor { margin-top: 6px; }
.an-body { margin-top: 8px; }
.an-loading { font-size: .88rem; }
.an-group { margin-top: 14px; }
.an-group-title {
  color: var(--accent); font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 8px;
}
/* telemetria em lista: rótulo à esquerda, valor à direita */
.tele-list { list-style: none; margin: 0; padding: 0; }
.tele-list li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 7px 2px; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.tele-list li:last-child { border-bottom: none; }
.tele-l { color: var(--muted); }
.tele-v { font-weight: 700; white-space: nowrap; text-align: right; }
.tele-u { color: var(--muted); font-weight: 500; font-size: .8rem; }

/* ---------- utilidades ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
/* ---------- celular (<= 600px): topbar compacta + ajustes finos ---------- */
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; padding: 10px 13px; gap: 8px; }
  .brand { font-size: 1.04rem; }
  .brand .uh-logo { width: 1.15em; height: 1.15em; }
  .topbar nav { width: 100%; gap: 4px; }
  .nav-link { padding: 6px 9px; font-size: .82rem; }
  .nav-sep { display: none; }
  .topbar .user { margin-left: auto; font-size: .78rem; gap: 5px; }
  .topbar .user .avatar { width: 22px; height: 22px; font-size: .72rem; }
  .icon-btn { width: 32px; height: 32px; }

  .container { padding: 14px 12px 8px; }
  h1 { font-size: 1.3rem; }
  .page-head { margin-bottom: 16px; }
  .panel { padding: 16px 15px; }

  .hero { padding: 15px 16px; }
  .hero .hero-greeting { font-size: 1.25rem; }
  .hero-status { width: 100%; }

  .cards { gap: 12px; }
  .card { padding: 15px 16px; }
  .card-value { font-size: 1.5rem; }

  .detail-head { flex-wrap: wrap; gap: 8px; }
  .cmp-stats { grid-template-columns: 1fr; }
  .ob-step { padding: 16px; gap: 12px; }
  .util-banner-top strong { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }


/* ---------- ícones SVG (substituem os emoji da UI de dados) ---------- */
.ico { flex: 0 0 auto; vertical-align: -.18em; }
h2.with-ico, h3.with-ico { display: flex; align-items: center; gap: 9px; }
h2.with-ico .ico { color: var(--accent); }
h2.with-ico .ico.i-green { color: var(--green); }
/* o ::before decorativo do h2.section não combina com um ícone à esquerda */
h2.with-ico.section::before { content: none; }
/* Ícone do cartão em tom neutro, pelo mesmo motivo da tarja: ele rotula a métrica,
   não codifica categoria nenhuma. */
.card-icon .ico { color: var(--muted); }
.btn .ico, .tab .ico, .status-chip .ico { vertical-align: -.2em; }
.plants-search-wrap { position: relative; flex: 1; min-width: 180px; display: flex; }
.plants-search-wrap .ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.plants-search-wrap .plants-search { padding-left: 38px; width: 100%; }

/* ---------- estado vazio dentro de um gráfico ---------- */
/* antes: o canvas mantinha ~420px de altura mesmo sem dados, deixando um vão enorme */
.chart-empty {
  display: grid; place-items: center; text-align: center;
  gap: 10px; padding: 34px 22px; min-height: 0;
  color: var(--muted); font-size: .88rem;
}
.chart-empty .ce-ic {
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.chart-empty p { margin: 0; max-width: 46ch; line-height: 1.5; }
.chart-box.is-empty { height: auto !important; min-height: 0 !important; }
.chart-box.is-empty > canvas { display: none; }

/* chips do comparativo: alinham ícone + texto */
.cmp-chip { display: inline-flex; align-items: center; gap: 6px; }
.plants-sort { line-height: 1.2; }

/* cards de usina: alinhamento entre colunas.
   Antes, um nome que quebrava em 2 linhas empurrava todo o conteúdo do card
   para baixo e desalinhava a grade inteira. */
.plant-card { display: grid; grid-template-rows: auto auto auto auto auto 1fr auto; justify-items: stretch; }
.plant-card .plant-vendor { justify-self: start; }
.plant-head { min-height: 2.6em; align-items: flex-start; }
.plant-card .plant-meta { align-self: end; }

/* ---------- paleta categórica dos gráficos ---------- */
/* Slots FIXOS, atribuídos por índice e nunca ciclados. A paleta anterior
   (#f5a623,#2ecc71,…) reprovava a validação: 5 de 8 cores fora da faixa de
   luminosidade no tema escuro e, pior, as séries 1 e 2 ficavam com ΔE 7,1 em
   protanopia — indistinguíveis para daltônicos vermelho-verde.
   Estes valores passam nas duas superfícies do app (#161d27 e #ffffff).
   O âmbar da marca NÃO entra aqui de propósito: cor de série igual à cor de
   ação faz dado parecer botão. */
:root {
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}
body.theme-light {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

/* ---------- algarismos tabulares ---------- */
/* Num painel de dados os números têm que alinhar em coluna e não "pular" durante
   a contagem animada dos KPIs. Sem isto, cada dígito tem largura própria e o
   valor tremia enquanto subia de 0 até o total. */
.card-value, .kpi-num, .plant-power, .plant-util-pct, .rank-val, .impact-val,
.impact-hero-val, .cmp-v, .kv strong, .util-banner-top strong, .edit-row input,
.plant-meta, .plant-est, .an-val, .vm-val, .cmp-k + .cmp-v, td, th {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.eflow .ef-val { font-variant-numeric: tabular-nums; }

/* posição no ranking — substitui as medalhas (classe is-lead, NÃO rank-top:
   esse nome já é o grid de 3 colunas da linha, e reusá-lo jogava o dígito
   para a primeira coluna, a 130px do lugar) — substitui as medalhas 🥇🥈🥉 (ranking de usina não é pódio) */
.rank-pos {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 20px; height: 20px; margin-right: 8px; border-radius: 6px;
  font-size: .7rem; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.rank-pos.is-lead {
  background: var(--accent-soft); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}
.rank-sub b { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* linha do ranking como controle do gráfico de ênfase */
.rank-item[data-plant] { cursor: pointer; border-radius: 8px; padding-left: 8px; padding-right: 8px;
  margin-left: -8px; margin-right: -8px; transition: background .14s ease; }
.rank-item[data-plant]:hover { background: var(--surface-2); }
.rank-item[data-plant]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rank-item.is-focus { background: var(--accent-soft); }
.rank-item.is-focus .rank-name { color: var(--text); }
/* valor que o portal não informa: nunca escrever "0,00", que afirmaria medição */
.kv strong.nao-informado { color: var(--muted); font-weight: 600; font-style: italic; }

/* Edição de acesso do colaborador: recolhida por padrão para a lista não virar um
   paredão de checkboxes quando houver vários colaboradores. */
.colab-edit { margin: 2px 0 10px; }
.colab-edit > summary {
  cursor: pointer; color: var(--muted); font-size: .82rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; list-style: none;
}
.colab-edit > summary::-webkit-details-marker { display: none; }
.colab-edit > summary:hover { color: var(--accent); }
.colab-edit[open] > summary { color: var(--text); }

/* Itens da lista de rotinas de relatório */
.rotina-item { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  margin: 10px 0; background: var(--surface-2); }
.rotina-topo { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  justify-content: space-between; }
.rotina-nome { font-weight: 700; display: inline-flex; align-items: baseline; gap: 8px; }
.rotina-sub { font-size: .8rem; margin-top: 4px; line-height: 1.5; }

/* Interruptor de cada rotina de relatório */
.rot-toggle { border: 0; background: none; padding: 0; cursor: pointer; display: inline-flex;
  align-items: center; vertical-align: middle; }
.rot-switch { display: block; width: 38px; height: 21px; border-radius: 999px;
  background: var(--border); position: relative; transition: background .18s ease; }
.rot-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px;
  height: 15px; border-radius: 50%; background: var(--muted);
  transition: transform .18s ease, background .18s ease; }
.rot-toggle.on .rot-switch { background: var(--accent); }
.rot-toggle.on .rot-switch::after { transform: translateX(17px); background: #fff; }
.rot-toggle:hover .rot-switch { filter: brightness(1.15); }
.rot-toggle:focus-visible .rot-switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.rotina-nome .inline-form { display: inline-flex; margin-right: 2px; }

/* Faixa do ambiente de homologação. Fica no topo, fixa e impossível de ignorar: o HMG é
   cópia fiel de produção e a semelhança é o próprio risco. */
.faixa-hmg {
  position: sticky; top: 0; z-index: 999;
  background: repeating-linear-gradient(45deg, #7c2d12, #7c2d12 12px, #9a3412 12px, #9a3412 24px);
  color: #fff; text-align: center; font: 700 .72rem/1 system-ui, sans-serif;
  letter-spacing: .08em; text-transform: uppercase; padding: 7px 12px;
}

/* códigos de recuperação do 2FA: monoespaçado e em grade, para conferir ao anotar */
.rec-codes { list-style:none; padding:0; margin:12px 0 0; display:grid;
  grid-template-columns:repeat(auto-fill, minmax(130px, 1fr)); gap:8px; }
.rec-codes li { font-family:ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size:.95rem; letter-spacing:.04em; background:var(--card-2, rgba(127,127,127,.09));
  border:1px solid var(--line, rgba(127,127,127,.22)); border-radius:8px;
  padding:9px 10px; text-align:center; }

/* QR do cadastro do 2FA: fundo branco fixo mesmo no tema escuro — QR invertido não é
   lido por leitor nenhum, e a página pode estar escura. */
.qr-wrap { display:flex; gap:20px; flex-wrap:wrap; align-items:flex-start; margin-top:12px; }
.qr-box { background:#fff; padding:12px; border-radius:12px; line-height:0;
  border:1px solid rgba(0,0,0,.12); flex:0 0 auto; }
.qr-box svg { display:block; width:230px; height:230px; }
.qr-ajuda { flex:1 1 260px; min-width:240px; font-size:.88rem; color:var(--muted);
  line-height:1.55; }
.qr-ajuda b { color:var(--ink, inherit); }

/* Redefinição de senha do colaborador: separada visualmente do formulário de acesso,
   para não parecer parte dele (são dois formulários com botões diferentes). */
.colab-senha { margin-top:14px; padding-top:12px;
  border-top:1px dashed var(--line, rgba(127,127,127,.25)); }

/* ---------- alarmes do fabricante ---------- */
/* O status "alerta" é um rótulo; o alarme é a frase que resolve o problema ("Falha de rede
   CA desde 10h07"). Tratado como conteúdo de leitura, não como badge. */
.alarme-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.alarme {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--yellow); border-radius: var(--radius-sm); padding: 12px 14px;
}
.alarme-grave { border-left-color: var(--red); }
.alarme-topo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.alarme-topo strong { font-size: .96rem; }
.alarme-nivel {
  font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 2px 9px;
}
.alarme-grave .alarme-nivel { color: var(--red); }
.alarme-meta { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.alarme-causa { margin: 8px 0 0; font-size: .88rem; line-height: 1.45; }
.alarme-sugestao {
  margin: 8px 0 0; font-size: .85rem; line-height: 1.45; color: var(--muted);
  border-left: 2px solid var(--border); padding-left: 10px;
}

/* ---------- usinas de uma rotina de relatório ---------- */
.rot-usinas { margin: 12px 0 0; }
.rot-usinas-tit { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 7px; }
.rot-usinas-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; }
.rot-usina { display: flex; align-items: center; gap: 7px; font-size: .88rem; cursor: pointer; }
.rot-usina input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* leitura de string: tensão · corrente · potência na mesma linha */
.tele-sep { color: var(--border); margin: 0 2px; }
.tele-nota { color: var(--muted); font-size: .78rem; font-style: italic; padding: 6px 2px 2px; }

/* string com tensão e sem corrente: o inversor segue "online" e ela não produz */
.tele-suspeita { background: color-mix(in srgb, var(--red) 10%, transparent); border-radius: 6px; }
.tele-flag { color: var(--red); font-weight: 900; }

/* ---------- histórico de paradas ---------- */
.ep-lista { list-style: none; margin: 0; padding: 0; }
.ep {
  display: grid; grid-template-columns: 54px 150px 68px 1fr; gap: 10px; align-items: baseline;
  padding: 7px 2px; border-bottom: 1px solid var(--border); font-size: .86rem;
  font-variant-numeric: tabular-nums;
}
.ep:last-child { border-bottom: 0; }
.ep-quando { color: var(--muted); }
.ep-faixa { font-weight: 600; }
.ep-dur { color: var(--accent); font-weight: 700; }
.ep-tipo { color: var(--muted); font-size: .82rem; }
.ep-falha .ep-dur { color: var(--red); }
@media (max-width: 560px) {
  .ep { grid-template-columns: 50px 1fr 58px; }
  .ep-tipo { grid-column: 2 / -1; }
}

/* ---------- cartão de destaque (o número mais olhado da tela) ---------- */
.card-destaque .card-value { font-size: clamp(2.1rem, 3.4vw, 2.9rem); }
.card-destaque { background: linear-gradient(145deg, var(--surface-2), var(--surface)); }

/* atalho para a tela de parede */
.chip-noc { text-decoration: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.chip-noc:hover { border-color: var(--accent); color: var(--accent); }

/* ícone de clima no cartão: alinhado à linha de texto, na cor da marca */
.plant-est .pe-ico { display: inline-flex; color: var(--accent-2); }
.plant-est .pe-ico svg { display: block; }

/* ---------- identidade do cartão: nome e portal na mesma linha ---------- */
.plant-ident { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
.plant-ident .plant-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plant-vendor-mini {
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; color: var(--muted);
  text-transform: uppercase; flex: 0 0 auto;
}

/* ---------- pulso quando o valor muda ---------- */
/* A página recarrega sozinha a cada ciclo; sem um sinal, o número novo chega igual ao
   velho e a atualização passa despercebida. Discreto de propósito: é um piscar de olho,
   não um alarme. Quem pediu menos movimento no sistema não vê nada (regra global de
   prefers-reduced-motion desliga animações). */
@keyframes uh-pulso {
  0%   { color: var(--accent-2); text-shadow: 0 0 18px var(--accent-soft); }
  100% { color: inherit; text-shadow: none; }
}
.valor-mudou { animation: uh-pulso 1.4s ease-out; }

/* ---------- caixa de confirmação (<dialog>) ---------- */
.dlg {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 22px 24px;
  max-width: 540px; width: calc(100% - 32px);
}
.dlg::backdrop { background: rgba(5, 9, 14, .62); backdrop-filter: blur(2px); }
.dlg h3 { font-size: 1.02rem; }
.dlg-acoes { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- situação do colaborador + registro de acessos ---------- */
.sit {
  display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent;
}
.sit-ativo     { color: #9be8bd; background: rgba(46,204,113,.12);  border-color: rgba(46,204,113,.38); }
.sit-convidado { color: #f3c08a; background: rgba(242,112,27,.13);  border-color: rgba(242,112,27,.42); }
.sit-falha     { color: #ff9b8f; background: rgba(231,76,60,.12);   border-color: rgba(231,76,60,.42); }
.sit-mudo      { color: var(--muted); background: var(--surface-2); border-color: var(--border); }

.tabela-rolagem { overflow-x: auto; }
.tabela-acessos { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tabela-acessos th {
  text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--border);
}
.tabela-acessos td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); }
.tabela-acessos tr:last-child td { border-bottom: none; }
.tabela-acessos .nowrap { white-space: nowrap; }

/* Sem resposta do portal: cinza, porque "não sei" não é "parou". */
.sc-unknown .sc-dot { background: var(--muted); }

/* Portal no rodapé do cartão, ao lado da capacidade: ele perdeu a disputa pela linha do
   nome de propósito (ver o comentário no dashboard.html). */
.plant-meta-fim { display: inline-flex; align-items: baseline; gap: 7px; white-space: nowrap; }

/* ---------- selo do vigia no cartão da usina ---------- */
/* Só aparece quando houve queda contra a linha de base DELA, num dia fechado. Dois tons:
   âmbar é "olha isso", vermelho é o mesmo corte em que o vigia já mandou e-mail. */
.plant-vigia {
  display: flex; align-items: center; gap: 7px; margin-top: 8px;
  padding: 7px 10px; border-radius: 10px; font-size: .78rem; line-height: 1.3;
  border: 1px solid transparent;
}
.plant-vigia svg { flex: 0 0 auto; }
.pv-atencao { background: rgba(241,196,15,.1);  border-color: rgba(241,196,15,.34); color: #f3d27a; }
.pv-grave   { background: rgba(231,76,60,.11);  border-color: rgba(231,76,60,.4);   color: #ff9b8f; }
.plant-vigia strong { font-weight: 800; }
.sit-expirado  { color: #ff9b8f; background: rgba(231,76,60,.12);  border-color: rgba(231,76,60,.42); }

/* ---------- geração compartilhada (créditos) ---------- */
.valor-ruim { color: var(--red); }
.gd-ucs { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 12px; }
.gd-uc {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; font-size: .86rem; transition: border-color .18s, transform .18s;
}
.gd-uc:hover { border-color: var(--accent); transform: translateY(-1px); }
.gd-uc .muted { font-size: .76rem; }
.gd-uc-desc { color: var(--accent-2); font-weight: 700; font-size: .78rem; }
/* Entrada de fatura: campo pequeno, muitos por linha — é digitação em série. */
.gd-itens input[type="text"] {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; color: var(--text); font-size: .84rem;
}
.gd-itens td { padding: 4px 6px 4px 0; }
/* Prévia do e-mail dentro da tela: o e-mail tem fundo próprio e não deve herdar o tema. */
.gd-previa { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 12px; }
