:root{
  --bg:#0b1220;
  --text:#e7eefc;
  --muted:#a9b6d3;
  --line:rgba(255,255,255,.10);

  --ok:#3ddc84;
  --warn:#f5a524;
  --crit:#ff4d4f;
  --info:#4aa3ff;

  --offline:#9aa4b2;
}

*{ box-sizing:border-box; }
html, body { min-height: 100%; }

html{
  background: var(--bg); /* evita “fundo branco”/emenda em mobile */
}

body{
  margin:0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  /* mesmo background que você já tinha */
  background:
    radial-gradient(1000px 600px at 20% 0%, rgba(74,163,255,.18), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, rgba(61,220,132,.10), transparent 55%),
    var(--bg);

  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: scroll; /* importante no mobile */
  color: var(--text);
}
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.topbar{
  position:sticky; top:0; z-index:5;
  backdrop-filter: blur(10px);
  background: rgba(10,18,34,.72);
  border-bottom:1px solid var(--line);
}

/* ---- header layout (3 colunas) ---- */
.topbar-inner{
  max-width:1200px; margin:0 auto;
  padding:14px 16px;
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  gap:16px;
}

.brand{ display:flex; align-items:center; gap:12px; }
.brand-text h1{ font-size:38px; margin:0; letter-spacing:.2px; }
.subtitle{ font-size:12px; color:var(--muted); margin-top:2px; }

/* centro: nome do customer */
.customer-center{
  display:flex;
  align-items:center;
  justify-content:center;
  min-width: 0;
}
.customer-name{
  font-size:28px;
  font-weight:900;
  letter-spacing:.2px;
  text-align:center;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 520px;
}

.topbar-right{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
}

.api-status, .clock{
  font-size:12px; color:var(--muted);
  padding:6px 10px;
  border:1px solid var(--line);
  border-radius:10px;
  background: rgba(255,255,255,.03);
}

/* input + botão */
.customer-picker{
  display:flex;
  align-items:center;
  gap:8px;
}

.input{
  width: 100px;
  padding:9px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
  outline: none;
  font-weight:700;
  font-size:12px;
}
.input::placeholder{
  color: rgba(169,182,211,.75);
}
.input:focus{
  border-color: rgba(255,255,255,.22);
}

.container{
  max-width:1200px;
  margin:0 auto;
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:16px;
}

.grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap:14px;
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid var(--line);
  border-radius:18px;
  box-shadow: 0 10px 26px rgba(0,0,0,.25);
  overflow:hidden;
}
.sensor-card{
  padding:14px;
  cursor:pointer;
  transition: transform .08s ease, border-color .08s ease;
}
.sensor-card:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.18);
}

/* ===== Card layout (rascunho) ===== */
.sensor-card-inner{ display:flex; flex-direction:column; gap:12px; }

.sensor-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}
.sensor-title{ display:flex; flex-direction:column; gap:4px; }
.sensor-name{ font-size:16px; font-weight:800; letter-spacing:.2px; color:var(--text); }
.sensor-id{ font-size:11px; color:var(--muted); opacity:.9; user-select:all; }

.sensor-actions{ display:flex; gap:8px; }
.icon-btn{
  width:34px; height:34px;
  border-radius:12px;
  border:1px solid rgba(74,163,255,.25);
  background: rgba(74,163,255,.07);
  color:var(--info);
  cursor:pointer;
  display:grid;
  place-items:center;
  font-size:14px;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover{ background: rgba(74,163,255,.15); border-color: rgba(74,163,255,.5); color:var(--info); }

.sensor-body{
  display:grid;
  grid-template-columns: 1.05fr 1.25fr;
  gap:12px;
}

/* Painel esquerdo */
.temp-panel{
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  background: rgba(0,0,0,.10);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.panel-label{
  font-size:12px;
  color:var(--muted);
  margin-bottom:10px;
}
.temp-core{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.thermo-wrap{
  position: relative;
  width: 48px;
  display: flex;
  justify-content: center;
}

/* Termômetro vertical */
.thermo-vert{
  position: relative;
  height: 190px;
  width: 64px;
  min-width: 64px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Ticks */
.thermo-ticks{
  position: absolute;
  left: -22px;
  top: 0;
  height: 100%;
  width: 36px;
  pointer-events: none;
}
.tick{
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.tick::after{
  content:"";
  width: 8px;
  height: 1px;
  background: rgba(255,255,255,.35);
}

/* Barra */
.thermo-bar{
  position: relative;
  width: 26px;
  height: 190px;
  border-radius: 5px;
  overflow: hidden;
  background: #1b263d;
  border: 1px solid rgba(255,255,255,.25);
  z-index: 2;
}
.thermo-fill{
  position: absolute;
  inset: 0;
  background: rgba(61,220,132,.35);
}
.thermo-marker{
  position: absolute;
  left: -18px;
  width: 52px;
  height: 4px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255,255,255,.55);
  z-index: 3;
}

.temp-num{
  font-size:44px;
  font-weight:900;
  letter-spacing:-.8px;
}
.temp-unit{ font-size:14px; color:var(--muted); }
.temp-state{ display: none; }

.temp-panel.ok .temp-num{ color: var(--ok); }
.temp-panel.warn .temp-num{ color: var(--warn); }
.temp-panel.crit .temp-num{ color: var(--crit); }
.temp-panel.offline .temp-num{ color: var(--offline); }

/* Painel direito */
.info-panel{
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  background: rgba(0,0,0,.08);
  display:flex;
  flex-direction:column;
  gap:8px;
}
.info-row{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
}
.info-row .k{ font-size:12px; color:var(--muted); }
.info-row .v{
  font-size:13px;
  color:var(--text);
  text-align:right;
  word-break:break-all;
}
.info-divider{ height:1px; background: var(--line); margin:4px 0; }

.v.ok{ color: var(--ok); font-weight:800; }
.v.bad{ color: var(--crit); font-weight:800; }
.v.dim{ color: var(--offline); font-weight:800; }

.btn{
  border:1px solid var(--line);
  background: rgba(255,255,255,.06);
  color:var(--text);
  border-radius:12px;
  padding:9px 12px;
  font-weight:650;
  font-size:12px;
  cursor:pointer;
}
.btn:hover{ border-color: rgba(255,255,255,.20); }
.btn.subtle{ background: rgba(255,255,255,.03); color: var(--muted); }

/* Alarmes */
.alarms{
  padding:14px;
  border:1px solid var(--line);
  border-radius:18px;
  background: rgba(255,255,255,.03);
}
.alarms-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.alarms-head h3{ margin:0; font-size:14px; }

.alarms-list{ display:flex; flex-direction:column; gap:8px; }
.alarm-item{
  padding:10px;
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(0,0,0,.10);
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.alarm-left{ display:flex; flex-direction:column; gap:6px; }

.alarm-sensor{ display:flex; flex-direction:column; gap:2px; }
.alarm-sensor .name{ font-size:13px; font-weight:900; }
.alarm-sensor .id{ font-size:11px; color:var(--muted); opacity:.9; }

.alarm-meta{ font-size:11px; color:var(--muted); }
.alarm-tag{
  font-size:11px;
  padding:5px 8px;
  border-radius:999px;
  border:1px solid var(--line);
  white-space:nowrap;
}
.alarm-tag.warn{ color:var(--warn); border-color: rgba(245,165,36,.35); }
.alarm-tag.crit{ color:var(--crit); border-color: rgba(255,77,79,.35); }
.alarm-tag.info{ color:var(--info); border-color: rgba(74,163,255,.35); }
.alarm-tag.offline{ color:var(--offline); border-color: rgba(154,164,178,.35); }

.empty{
  padding:14px;
  border:1px dashed var(--line);
  border-radius:14px;
  color:var(--muted);
  text-align:center;
}

/* Modal */
.modal-backdrop{
  position:fixed; inset:0;
  z-index: 9999;
  background: rgba(0,0,0,.55);
  display:flex; align-items:center; justify-content:center;
  padding:18px;
}
.modal{
  position: relative;
  width:min(900px, 100%);
  background: rgba(10,18,34,.92);
  border:1px solid var(--line);
  border-radius:18px;
  overflow:hidden;
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px;
  border-bottom:1px solid var(--line);
}
.modal-title{ font-size:14px; font-weight:900; }
.modal-sub{ font-size:12px; color:var(--muted); margin-top:2px; }
.modal-body{ padding:14px; }
.chart-wrap{
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  background: rgba(0,0,0,.12);
}
.modal-foot{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:14px;
  border-top:1px solid var(--line);
}
.hidden{ display:none; }

@media (max-width: 1100px){
  .topbar-inner{
    grid-template-columns: 1fr;
    row-gap: 10px;
  }
  .customer-center{ justify-content:flex-start; }
  .customer-name{ max-width: 100%; text-align:left; }
  .topbar-right{ justify-content:flex-start; flex-wrap:wrap; }
}

@media (max-width: 680px){
  .sensor-body{ grid-template-columns: 1fr; }
  .input{ width: 160px; }
}

/* Topo do painel de temperatura */
.temp-head{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-bottom:10px;
}
.temp-head .panel-label{ margin:0; }
.temp-head .temp-inline{
  display:flex;
  align-items:baseline;
  gap:6px;
}
.temp-head .temp-inline .temp-num{
  font-size:36px;
  font-weight:900;
  letter-spacing:-.6px;
  line-height:1;
}
.temp-head .temp-inline .temp-unit{
  font-size:13px;
  color:var(--muted);
}
.temp-head .temp-state{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
}
.temp-panel.ok .temp-head .temp-num{ color: var(--ok); }
.temp-panel.warn .temp-head .temp-num{ color: var(--warn); }
.temp-panel.crit .temp-head .temp-num{ color: var(--crit); }
.temp-panel.offline .temp-head .temp-num{ color: var(--offline); }


/* Impede scroll do fundo quando modal está aberto */
body.modal-open{ overflow: hidden; }


/* ===== Histórico (modal) ===== */
.modal-backdrop{
  position:fixed;
  inset:0;
  z-index:99999;
  background:rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
}
.modal-backdrop.hidden{ display:none; }

.modal{
  width:min(1180px, 96vw);
  max-height:92vh;
  background:rgba(18,25,44,.98);
  border:1px solid var(--line);
  border-radius:16px;
  overflow:hidden;
  box-shadow:0 20px 70px rgba(0,0,0,.45);
  position:relative;
}

.modal-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid var(--line);
}
.modal-head-text{ display:flex; flex-direction:column; gap:4px; }
.modal-head-actions{ display:flex; gap:10px; align-items:center; }
.modal-title{ font-size:18px; font-weight:800; letter-spacing:.2px; }
.modal-sub{ color:var(--muted); font-size:13px; }

.modal-toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  padding:10px 16px;
  border-bottom:1px solid var(--line);
  align-items:end;
}
.modal-toolbar .range{
  display:flex;
  gap:10px;
  align-items:end;
  flex-wrap:wrap;
}
.field{ display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--muted); }
.field input{
  height:34px;
  padding:6px 10px;
  border-radius:10px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.06);
  color:var(--text);
}
.modal-toolbar .quick, .modal-toolbar .yzoom{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
}
.chip{
  height:34px;
  padding:0 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--text);
  cursor:pointer;
  font-weight:700;
  font-size:12px;
}
.chip:hover{ background:rgba(255,255,255,.08); }

.modal-body{ padding:12px 16px 14px; }
.chart-wrap{
  height:380px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.12);
  padding:10px;
}
.limits{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:10px;
}
.pill.warn{ border-color: rgba(245,165,36,.35); }
.pill.crit{ border-color: rgba(255,77,79,.35); }

.modal-meta{
  margin-top:20px;
  color:var(--text);
  font-weight:800;
  font-size:13px;
}
.modal-help{
  margin-top:6px;
  margin-bottom: 20px;
  color:var(--muted);
  font-size:12px;
}

.modal-foot{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:12px 16px;
  border-top:1px solid var(--line);
}


.select-input{
  width: 220px;
  appearance: none;
}

.user-pill{
  font-size:12px;
  color:var(--text);
  padding:6px 10px;
  border:1px solid var(--line);
  border-radius:10px;
  background: rgba(255,255,255,.03);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hidden{
  display:none !important;
}

/* ============================================================
   Adições – NÃO remove nem altera regras acima
============================================================ */

/* --- Logo --- */
.brand-logo { height: 64px; display: block; }
.brand-text .subtitle { line-height: 1.4; }
.brand-text .subtitle div { font-size: 12px; color: var(--muted); }

/* --- Customer center: nome + status empilhados --- */
.customer-center { flex-direction: column; gap: 4px; }
.customer-center .api-status {
  border: none;
  background: none;
  padding: 2px 0;
  font-size: 11px;
}

/* --- Select oculto (modelo JS) --- */
.hidden-select { display: none !important; }

/* --- Custom dropdown de customer --- */
.cust-dropdown { position: relative; }
.cust-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 140px;
  justify-content: space-between;
}
.dropdown-caret { font-size: 9px; opacity: .6; }
.cust-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: rgba(18,25,44,.98);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.50);
  overflow: hidden;
  z-index: 200;
}
.cust-dropdown-item {
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.cust-dropdown-item:hover { background: rgba(255,255,255,.06); }
.cust-dropdown-item.active { color: var(--info); font-weight: 800; }

/* --- Grupo usuário/sair (coluna, alinhado à direita) --- */
.user-auth-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.user-name-plain {
  font-size: 12px;
  color: var(--muted);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Cards: ocultar apenas os botões de ação (status icons ficam visíveis) --- */
.sensor-card .sensor-actions .icon-btn { display: none; }

/* --- Cards: ícones de status no canto do card --- */
.card-status-icons {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.status-icon.online  { color: var(--ok);      filter: drop-shadow(0 0 4px var(--ok)); }
.status-icon.offline { color: var(--offline); }
.alarm-icon {
  font-size: 13px;
  font-weight: 900;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.alarm-icon.crit { color: var(--crit); }
.alarm-icon.warn { color: var(--warn); }

/* --- Status icon: 3x maior --- */
.status-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.status-icon svg { width: 14px; height: 14px; }

/* --- Nome do usuário acima do grupo customer+sair --- */
.topbar-right {
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.topbar-right .user-name-plain {
  order: -1;
}
.topbar-right-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== TELA DE LOGIN ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background:
    radial-gradient(1000px 600px at 20% 0%, rgba(74,163,255,.18), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, rgba(61,220,132,.10), transparent 55%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-screen.hidden { display: none !important; }
.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 40px 36px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo-wrap {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-img {
  height: 80px;
  width: auto;
  margin: 0 auto;
  display: block;
}
.login-logo-sub {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.6;
}
.login-divider {
  height: 1px;
  background: var(--line);
  margin-bottom: 26px;
}
.login-field-group { margin-bottom: 16px; }
.login-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
.login-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
}
.login-input:focus { border-color: rgba(74,163,255,.55); }
.login-btn {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #1a4fa3, var(--info));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity .2s, transform .1s;
  font-family: inherit;
}
.login-btn:hover { opacity: .88; transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-error {
  color: var(--crit);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
}


/* --- Cards: ocultar info-panel no resumo; sensor-body usa coluna única --- */
.sensor-card .info-panel { display: none; }
.sensor-card .sensor-body { grid-template-columns: 1fr; }

/* --- Campo senha com botão olho --- */
.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.login-input-wrap .login-input {
  padding-right: 44px;
}
.login-eye-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--muted);
  padding: 4px;
  line-height: 1;
  opacity: .7;
  transition: opacity .15s;
}
.login-eye-btn:hover { opacity: 1; }

.login-forgot-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-top: 12px;
  cursor: pointer;
  transition: color .15s;
  padding: 0;
}
.login-forgot-link:hover { color: var(--info); }

.login-reset-hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 0 0 16px;
  line-height: 1.5;
}
.login-success {
  font-size: 13px;
  color: var(--ok);
  text-align: center;
  margin-top: 10px;
  font-weight: 600;
}


/* ── Mobile topbar: 2 linhas ─────────────────────────────────────── */
@media (max-width: 600px) {

  /*
   * Estratégia: topbar-inner vira grid de 2 colunas (logo | ações).
   * .customer-center ocupa linha inteira abaixo via grid-column: 1/-1
   * Ordem visual: linha1 = brand + topbar-right / linha2 = customer-center
   */
  .topbar-inner {
    padding: 7px 12px 6px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 0;
  }

  /* logo: coluna 1, linha 1 */
  .topbar-inner > .brand {
    grid-column: 1;
    grid-row: 1;
  }

  /* ações: coluna 2, linha 1 */
  .topbar-inner > .topbar-right {
    grid-column: 2;
    grid-row: 1;
  }

  /* customer center: linha 2 inteira, centralizado */
  .topbar-inner > .customer-center {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0 2px;
    border-top: 1px solid rgba(255,255,255,.06);
    margin-top: 5px;
  }

  /* logo menor */
  .brand-logo { height: 28px; }
  .brand-text h1 { font-size: 18px; }
  .subtitle, .brand-text .subtitle div { font-size: 9px; line-height: 1.3; }

  /* customer name */
  .customer-name {
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
    text-align: center;
  }
  .customer-center .api-status { font-size: 9px; padding: 1px 5px; }

  /* lado direito compacto */
  .topbar-right {
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
  }
  .topbar-right .user-name-plain { font-size: 10px; }
  .topbar-right-row { gap: 5px; }
  .topbar-right-row .btn { font-size: 11px; padding: 5px 9px; }
  .api-status, .clock { font-size: 9px; padding: 3px 7px; }

  /* gráfico: fontes menores */
  .hist-chart-wrap { font-size: 9px; }
}


/* ============================================================
   Modal de Configurações de Usuário — alinhado ao padrão de sensor.html
============================================================ */
.btn-user-profile{
  width:38px;
  height:38px;
  border-radius:12px;
  border:1px solid rgba(74,163,255,.25);
  background:rgba(74,163,255,.07);
  color:var(--info);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  position:relative;
  transition:background .15s,border-color .15s,color .15s,transform .08s ease;
}
.btn-user-profile:hover{
  background:rgba(74,163,255,.15);
  border-color:rgba(74,163,255,.5);
  color:var(--info);
  transform:translateY(-1px);
}
.btn-user-profile::before{
  content:"";
  width:16px;
  height:16px;
  border:2px solid currentColor;
  border-radius:50%;
  position:absolute;
  top:7px;
  left:50%;
  transform:translateX(-50%);
}
.btn-user-profile::after{
  content:"";
  width:18px;
  height:9px;
  border:2px solid currentColor;
  border-top:none;
  border-radius:0 0 12px 12px;
  position:absolute;
  bottom:6px;
  left:50%;
  transform:translateX(-50%);
}

.user-name-plain{ cursor:pointer; }

.cfg-modal-backdrop{
  position:fixed;
  inset:0;
  z-index:9998;
  background:rgba(0,0,0,.6);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
}
.cfg-modal-backdrop.hidden{ display:none !important; }

.cfg-modal{
  background:rgba(18,25,44,.98);
  border:1px solid var(--line);
  border-radius:20px;
  width:min(560px,100%);
  max-height:90vh;
  display:flex;
  flex-direction:column;
  box-shadow:0 24px 70px rgba(0,0,0,.55);
  overflow:hidden;
}

.cfg-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:16px 18px 14px;
  border-bottom:1px solid var(--line);
  flex-shrink:0;
}
.cfg-modal-head span{
  font-size:20px;
  font-weight:800;
  color:var(--text);
  line-height:1.2;
}
.cfg-modal-body{
  padding:18px;
  overflow-y:auto;
  flex:1;
}

.cfg-section{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding-bottom:14px;
  border-bottom:1px solid var(--line);
  margin-bottom:4px;
}
.cfg-section:last-child{
  border-bottom:none;
  padding-bottom:0;
}
.cfg-section-title{
  font-size:10px;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--muted);
  margin-bottom:2px;
}

.config-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}
.cfg-field,
.config-field{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.cfg-field label,
.config-field label{
  font-size:11px;
  color:var(--muted);
}
.cfg-val{
  background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.09);
  border-radius:8px;
  color:var(--text);
  font-size:14px;
  font-weight:600;
  padding:8px 10px;
  min-height:36px;
  display:flex;
  align-items:center;
}
.config-field input{
  background:rgba(255,255,255,.06);
  border:1px solid var(--line);
  border-radius:8px;
  color:var(--text);
  font-size:14px;
  padding:8px 10px;
  outline:none;
  width:100%;
  box-sizing:border-box;
  transition:border-color .2s;
}
.config-field input:focus{ border-color:rgba(74,163,255,.55); }

.config-actions{
  display:flex;
  gap:8px;
  margin-top:4px;
}
.btn-save{
  background:linear-gradient(135deg,#1a4fa3,var(--info));
  border:none;
  border-radius:10px;
  color:#fff;
  padding:9px 18px;
  font-size:13px;
  font-weight:700;
  cursor:pointer;
  transition:opacity .2s;
}
.btn-save:hover{ opacity:.85; }
.btn-cancel{
  background:transparent;
  border:1px solid var(--line);
  border-radius:10px;
  color:var(--muted);
  padding:9px 18px;
  font-size:13px;
  cursor:pointer;
}
.btn-cancel:hover{
  color:var(--text);
  border-color:rgba(255,255,255,.2);
}
.save-feedback{
  font-size:12px;
  color:var(--ok);
  min-height:16px;
  line-height:1.5;
}
.save-feedback.err{ color:var(--crit); }

.profile-grid-2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}
.profile-help{
  font-size:10px;
  color:var(--muted);
  margin-top:3px;
}
.profile-toggle-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top:4px;
}
.profile-toggle-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-radius:12px;
  background:rgba(255,255,255,.04);
  border:1px solid var(--line);
}
.profile-toggle-name{
  font-size:13px;
  font-weight:700;
  color:var(--text);
}
.profile-toggle-right{
  display:flex;
  align-items:center;
  gap:10px;
  flex-shrink:0;
}
.profile-toggle-state{
  font-size:12px;
  color:var(--muted);
  min-width:64px;
  text-align:right;
}
.profile-toggle-item.is-active .profile-toggle-state{ color:var(--text); }
.profile-toggle-item.is-error .profile-toggle-state{ color:var(--crit); }
.profile-toggle-item.is-disabled{ opacity:.7; }

.switch{
  width:40px;
  height:22px;
  border-radius:11px;
  background:rgba(255,255,255,.12);
  border:1px solid var(--line);
  position:relative;
  display:inline-block;
  flex-shrink:0;
}
.switch input{
  position:absolute;
  inset:0;
  opacity:0;
  cursor:pointer;
}
.switch-slider{
  position:absolute;
  inset:0;
  border-radius:11px;
  transition:background .2s;
}
.switch-slider::after{
  content:"";
  position:absolute;
  top:3px;
  left:3px;
  width:14px;
  height:14px;
  border-radius:50%;
  background:#fff;
  transition:left .2s;
  box-shadow:0 1px 4px rgba(0,0,0,.35);
}
.switch input:checked + .switch-slider{
  background:var(--info);
}
.switch input:checked + .switch-slider::after{
  left:19px;
}
.switch input:disabled + .switch-slider{
  opacity:.6;
}

@media (max-width: 640px){
  .cfg-modal{ width:min(560px, calc(100vw - 16px)); max-height:92vh; }
  .cfg-modal-head{ padding:14px 14px 12px; }
  .cfg-modal-head span{ font-size:18px; }
  .cfg-modal-body{ padding:14px; }
  .config-row,
  .profile-grid-2{ grid-template-columns:1fr; }
  .profile-toggle-item{ align-items:flex-start; }
  .profile-toggle-right{ margin-left:auto; }
}

.profile-readonly-block{
  margin-top: 10px;
}

.profile-readonly-block + .profile-readonly-block{
  margin-top: 14px;
}

.profile-info-label{
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.profile-info-value{
  font-size: 15px;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}

#profileView .cfg-section,
#profileEdit .cfg-section{
  margin-bottom: 18px;
}

#profileEdit .config-field + .config-field{
  margin-top: 14px;
}

.profile-toggle-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-modal-body{
  display:flex;
  flex-direction:column;
  gap:0;
}

.profile-mode{
  display:flex;
  flex-direction:column;
  gap:0;
}

.profile-readonly-block{
  margin-top:10px;
}

.profile-readonly-block + .profile-readonly-block{
  margin-top:14px;
}

.profile-info-label{
  font-size:11px;
  color:var(--muted);
  margin-bottom:4px;
  font-weight:600;
  text-transform:none;
  letter-spacing:0;
}

.profile-info-value{
  font-size:14px;
  color:var(--text);
  line-height:1.4;
  word-break:break-word;
}

.profile-toggle-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top:4px;
}

#profileEdit .config-field + .config-field{
  margin-top:12px;
}

.profile-help{
  font-size:10px;
  color:var(--muted);
  margin-top:3px;
}

.btn-user-profile{
  width:34px;
  height:34px;
  border-radius:8px;

  display:flex;
  align-items:center;
  justify-content:center;

  border:1px solid var(--info);
  color:var(--info);
}

.btn-user-profile svg{
  width:18px;
  height:18px;
  stroke:var(--info);
  fill:none;
}

.btn-user-profile::before{
  content:"";
  width:18px;
  height:18px;
  display:block;

  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 21a8 8 0 10-16 0'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
}

.topbar-user-line{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
}

.user-name-plain{
  color: var(--info);
  font-weight: 500;
}

/* ===== Header usuário: versão final limpa ===== */
.topbar-user-line{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
}

.user-name-plain{
  color:var(--info);
  font-weight:600;
  white-space:nowrap;
  cursor:pointer;
  transition:opacity .15s ease, color .15s ease;
}

.user-name-plain:hover{
  opacity:.9;
  text-decoration:underline;
  text-underline-offset:2px;
}

/* botão do perfil */
.btn-user-profile{
  width:34px;
  height:34px;
  min-width:34px;
  border-radius:10px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border:1px solid var(--info);
  background:transparent;
  color:var(--info);
  cursor:pointer;
  position:relative;
}

.btn-user-profile:hover{
  background:rgba(74,163,255,.08);
}

/* mata pseudo-elementos antigos que estavam desenhando outro ícone */
.btn-user-profile::before,
.btn-user-profile::after{
  content:none !important;
  display:none !important;
}

/* ícone SVG final */
.btn-user-profile svg{
  width:18px;
  height:18px;
  display:block;
  fill:var(--info) !important;
  stroke:none !important;
}

/* botão relatório */
.btn-report{
  margin-left:6px;
}

/* estado loading botão */
.btn-report.loading{
  opacity:.6;
  pointer-events:none;
}

/* feedback relatório */
.hist-report-status{
  font-size:12px;
  margin-top:4px;
  color:#9aa4b2;
}

.hist-report-status.error{
  color:#ff6b6b;
}

.hist-report-status.success{
  color:#3ddc84;
}