:root {
  /* Fundo geral escuro (restaurado) */
  --bg: #0f1115;
  --panel: #1a1f29;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --gold: #DAA520;
  --gray-dark: #30343a;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial; background: var(--bg); color: var(--text); }

.header { background: #12151b; border-bottom: 1px solid #222632; }
.header-content { max-width: 1100px; margin: 0 auto; padding: 16px 20px 8px; display: flex; align-items: center; justify-content: space-between; }
.header-meta { max-width: 1100px; margin: 0 auto; padding: 0 20px 12px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.header-meta .left-meta { display: flex; align-items: flex-start; }
.right-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.header-meta small { font-size: 11px; color: #bbb; }
#appVersionRight { font-size: 11px; color: #bbb; font-weight: 500; text-align: right; }
.geo-link { color: #ffffff; text-decoration: underline; font-size: 14px; text-align: right; }
.farm-name { color: var(--gold); font-weight: 800; font-size: 28px; letter-spacing: 0.3px; text-shadow: 0 1px 1px rgba(0,0,0,0.6), 0 0 6px rgba(218,165,32,0.35); }

.silo-info {
  text-align: center;
  color: #e2e8f0;
}

.silo-name {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.silo-location {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.silo-property {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gold);
}

.silo-coordinates {
  font-size: 0.85rem;
  opacity: 0.8;
}
.logo { display: flex; align-items: center; gap: 15px; }
.logo-icon { font-size: 32px; }
.logo-text { display: flex; flex-direction: column; }
.logo h1 { margin: 0; font-size: 24px; font-weight: 700; color: var(--gold); }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

.status { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.status-item { display: flex; align-items: center; gap: 8px; background: var(--panel); padding: 8px 12px; border-radius: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; display: inline-block; }
.dot-online { background: #22c55e; }
#mqttDot.online { background: #22c55e; }
#mqttDot.offline { background: #ef4444; }
.status-item small { color: var(--muted); }

.dashboard { max-width: 1600px; margin: 12px auto; padding: 0 12px; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.stat-card { background: var(--panel); border: 1px solid #222632; border-radius: 10px; padding: 10px; }
.stat-title { font-size: 11px; color: var(--muted); }
.stat-value { font-size: 18px; font-weight: 600; margin-top: 4px; }
/* Linhas adicionais nos cartões de clima detalhado */
small.line { display: block; margin-top: 4px; color: var(--muted); }
#umidade_externa, #chuva_prevista, #data_coleta_externa { display: block; margin-top: 4px; }

/* Tornar 24h e 48h menores e sem negrito */
.forecast-card .stat-title { font-size: 10px; }
.forecast-card .stat-value { font-size: 12px; font-weight: 400; }

/* Cabeçalho "Previsão" centralizado em amarelo ouro */
.forecast-card .forecast-title {
  text-align: center;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* Centralizar conteúdo do card Clima (agora) */
.center-card .stat-title,
.center-card .stat-value,
.center-card small {
  text-align: center;
}

/* Aumentar a fonte da linha de Umidade para igualar a linha de cima (condição) */
#weatherNowMeta .big-meta {
  font-size: 18px;
  font-weight: 600;
  display: block;
}

.silo-section { margin-top: 24px; background: var(--panel); border: 1px solid #222632; border-radius: 12px; padding: 16px; }
.silo-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.update-info { color: var(--muted); font-size: 13px; }

.silo-container { display: grid; grid-template-columns: 1fr; align-items: center; gap: 10px; }
.silo-drawing { display: flex; justify-content: center; }
/* Tornar o silo maior e responsivo (escala pelo viewBox do SVG) */
.silo-drawing svg { width: 100vw; max-width: 1600px; height: auto; }

/* Removemos a numeração lateral dos níveis */

.sensor-rect { 
  stroke-width: 2px; 
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4)); 
  transition: all 0.2s ease;
}
.sensor-rect:hover {
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.6));
  transform: scale(1.05);
}
.sensor-temp { 
  font-size: 22px; 
  font-weight: 700; 
  fill: #000000; /* padrão preto; JS ajusta para tons de vermelho quando vazio */
  text-anchor: middle; 
  dominant-baseline: middle; 
  pointer-events: none; 
  /* remover contorno para letras sólidas no mobile */
  stroke: none;
  stroke-width: 0; 
}
/* Label do campo ORDEM (acima do retângulo) */
.sensor-order { 
  font-size: 13px; 
  font-weight: 600; 
  fill: #9aa4b2; 
  text-anchor: middle; 
  dominant-baseline: middle; 
  pointer-events: none; 
}

/* Numeração lateral discreta (um lado do silo) */
.sensor-order-side {
  font-size: 11px;
  font-weight: 600;
  fill: #8a94a3; /* discreto */
  pointer-events: none;
}

/* Cores por ocupação */
.fill-occupied { fill: #FFD24D; }
/* Prata para áreas sem grãos (silo vazio): cor natural do metal */
.fill-empty { fill: #C0C0C0; }

/* Bordas por temperatura */
.stroke-green { stroke: #00D084; }
.stroke-amber { stroke: #FFB900; }
.stroke-red { stroke: #FF4D4D; }

/* Animação de alerta */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.alert-pulse { animation: pulse 1.5s ease-in-out infinite; }

.tooltip { position: fixed; background: #0b0e13; border: 1px solid #222632; padding: 10px; border-radius: 10px; font-size: 12px; color: var(--text); pointer-events: none; z-index: 10; }
.tooltip .title { font-weight: 600; margin-bottom: 6px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat-card { padding: 8px; }
  .stat-title { font-size: 10px; }
  .stat-value { font-size: 16px; }
  .silo-container { grid-template-columns: 1fr; }
  .silo-drawing svg { width: 100vw; max-width: none; }
}

/* Mobile: ocupar mais altura da tela para o silo ficar grande e legível */
@media (max-width: 600px) {
  .dashboard { padding: 0 8px; }
  .silo-section { padding: 12px; }
  .silo-drawing svg {
    width: auto;           /* deixa o SVG ajustar pela altura para aumentar a imagem */
    height: 85vh;          /* ocupa 85% da altura da tela */
    max-height: 95vh;      /* segurança para não estourar */
  }
}
.silos-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.silo-card {
  background: var(--panel);
  border: 1px solid #222632;
  border-radius: 12px;
  padding: 12px;
}
.silo-title {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.silo-card svg { width: 100%; height: auto; }

/* Modal de mapa */
/* removido modal; usando link que abre nova página */

/* Sempre manter layout vertical - um silo abaixo do outro */
/* Link da fonte (OpenWeather) em branco para melhor visibilidade */
#data_coleta_externa a {
  color: #fff !important;
}

/* ===== Login Overlay ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.login-card {
  background: var(--panel);
  border: 1px solid #222632;
  border-radius: 12px;
  padding: 18px 16px;
  width: 340px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.35);
}
.login-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.login-header .logo-icon { font-size: 24px; }
.login-header h2 { margin: 0; font-size: 18px; color: var(--gold); }
.login-body { display: flex; flex-direction: column; gap: 8px; }
.login-body label { font-size: 12px; color: var(--muted); }
.login-body input {
  background: #0b0e13;
  border: 1px solid #222632;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
}
.login-btn {
  background: #1f6feb; /* azul leve */
  border: none;
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.login-btn:hover { background: #1a61d0; }
.login-msg { font-size: 12px; color: var(--red); min-height: 16px; }

/* Logout button */
.logout-btn {
  margin-top: 4px;
  background: #8B0000; /* vermelho escuro */
  border: 1px solid #5c0c0c;
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.logout-btn:hover { background: #a00000; }