/* ================= RESET & GENERALI ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: #1a1a1a;
  color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Sfondo tecnologico a punti animato */
.matrix-bg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background-image: radial-gradient(#3c702a 0.8px, transparent 0.8px);
  background-size: 4px 4px;
  opacity: 0.25;
  mask-image: linear-gradient(to top, rgba(0,0,0,1) 30%, rgba(0,0,0,0) 100%);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 30%, rgba(0,0,0,0) 100%);
  z-index: 1;
  pointer-events: none;
  animation: matrixRise 22s linear infinite;
}

@keyframes matrixRise {
  from { background-position-y: 0px; }
  to { background-position-y: -400px; }
}

.hidden { display: none !important; }

/* ================= LOGIN CARD ================= */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 5;
  width: 100%;
  max-width: 380px;
  padding: 20px;
}

.logo-area-login {
  font-size: 3.5rem;
  font-weight: 800;
  color: #4c8c35;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  letter-spacing: -2px;
}

.bracket { font-weight: 300; color: #4c8c35; }

.login-card {
  background-color: #121212;
  border: 1px solid #252525;
  border-radius: 24px;
  padding: 28px;
  width: 100%;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.login-card.visible { opacity: 1; transform: translateY(0); }

.input-group { display: flex; flex-direction: column; margin-bottom: 1.2rem; }
.input-group label { font-size: 0.85rem; font-weight: 600; color: #ffffff; margin-bottom: 8px; }
.input-group input {
  background-color: #1c1c1c;
  border: 1.5px solid #2d2d2d;
  border-radius: 12px;
  color: #ffffff;
  padding: 12px 16px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.input-group input:focus { border-color: #4c8c35; }

.error-msg {
  color: #ff4d4d;
  font-size: 0.8rem;
  text-align: center;
  margin-bottom: 1rem;
  display: none;
  font-weight: 600;
}

.btn-submit {
  width: 100%;
  background-color: #4c8c35;
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

/* ================= DASHBOARD ================= */
.dashboard-container {
  width: 95%;
  max-width: 1280px;
  background-color: #111111;
  border: 1px solid #222222;
  border-radius: 28px;
  padding: 24px;
  z-index: 5;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  animation: fadeIn 0.6s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid #222222;
  margin-bottom: 24px;
}

.logo-text-dash { font-size: 1.1rem; color: #eeeeee; }
.logo-text-dash strong { color: #4c8c35; }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  color: #888888;
}

.green-highlight { color: #4c8c35; font-weight: 600; }
.settings-btn {
  background-color: #222222;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.5fr 0.9fr;
  gap: 20px;
}

.dash-card {
  background-color: #161616;
  border: 1px solid #222222;
  border-radius: 24px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.dash-card h2 {
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: lowercase;
  color: #eeeeee;
  border-bottom: 1px solid #222222;
  padding-bottom: 12px;
  margin-bottom: 20px;
}

/* ================= RADAR CONSUMI ================= */
.radar-wrapper { display: flex; justify-content: center; margin: 10px 0; }
.radar-circle {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  position: relative;
  background-color: #111111;
  border: 1px solid #252525;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.radar-ring {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  z-index: 2;
}

.ring-1 { width: 50px; height: 50px; }
.ring-2 { width: 90px; height: 90px; }
.ring-3 { width: 130px; height: 130px; }

.ring-outer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  z-index: 1;
  transition: background 0.8s ease;
}

.ring-outer::after {
  content: '';
  position: absolute;
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  border-radius: 50%;
  background-color: #111111;
  z-index: 2;
}

.watt-display { text-align: center; margin: 15px 0 25px 0; }
.watt-value { display: block; font-size: 2.6rem; font-weight: 800; }
.watt-label { font-size: 0.75rem; color: #777777; }

.status-indicator-bar { display: flex; gap: 8px; }
.status-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 12px;
  text-align: center;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
}

.status-name { font-weight: 700; }
.status-range { font-size: 0.65rem; opacity: 0.8; margin-top: 2px; }
.state-disabled { background-color: #222222; color: #666666; border: 1px solid #2d2d2d; }

/* ================= COLONNA RINNOVABILE ================= */
.col-medium-double { display: flex; flex-direction: column; gap: 20px; }
.renewable-live-data { display: grid; grid-template-columns: 0.8fr 1.2fr; align-items: center; gap: 15px; }
.percentage-value { font-size: 3rem; font-weight: 800; color: #4c8c35; }
.percentage-label { font-size: 0.75rem; color: #999999; }

.chart-container { width: 100%; position: relative; }
.area-chart { width: 100%; height: 90px; }
.pulse-dot { animation: pulse 1.8s infinite; }
@keyframes pulse {
  0% { r: 3px; opacity: 0.6; }
  50% { r: 5px; opacity: 1; }
  100% { r: 3px; opacity: 0.6; }
}

.chart-timeline { display: flex; justify-content: space-between; font-size: 0.65rem; color: #555555; }
.sources-indicator-bar { display: flex; gap: 15px; margin-top: 15px; }
.source-pill {
  flex: 1;
  padding: 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.source-pill .dot-indicator { width: 6px; height: 6px; border-radius: 50%; }
.source-active { background-color: #4c8c35; color: #ffffff; }
.source-active .dot-indicator { background-color: #ffffff; box-shadow: 0 0 8px #ffffff; }
.source-inactive { background-color: #222222; color: #777777; border: 1px solid #2d2d2d; }
.source-inactive .dot-indicator { background-color: #444444; }

/* Storico Settimanale */
.weekly-arcs { display: flex; justify-content: space-between; }
.day-arc-wrapper { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 0.7rem; color: #777777; }
.circular-chart { width: 32px; height: 32px; }
.circle-bg { fill: none; stroke: #222222; stroke-width: 3.5; }
.circle { fill: none; stroke-width: 3.5; stroke-linecap: round; }
.red-arc .circle { stroke: #d32f2f; }
.yellow-arc .circle { stroke: #fbc02d; }
.green-arc .circle { stroke: #388e3c; }

/* ================= RADAR SOCIALITÀ ================= */
.social-radar-wrapper { display: flex; justify-content: center; margin: 15px 0; }
.social-radar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 1px dashed rgba(224, 86, 36, 0.2);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #111111;
  overflow: hidden;
  transition: border-color 0.8s, box-shadow 0.8s;
}

.social-ring { position: absolute; border: 1px solid rgba(255, 255, 255, 0.05); border-radius: 50%; }
.s-ring-1 { width: 45px; height: 45px; }
.s-ring-2 { width: 85px; height: 85px; }
.s-ring-3 { width: 120px; height: 120px; }

.social-radar::before {
  content: '';
  position: absolute;
  width: 50%; height: 50%;
  background: conic-gradient(from 0deg, rgba(224, 86, 36, 0.15) 0deg, transparent 90deg);
  transform-origin: bottom right;
  bottom: 50%; right: 50%;
  border-radius: 100% 0 0 0;
  animation: radar-sweep 4s linear infinite;
}

@keyframes radar-sweep {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.social-core {
  width: 20px; height: 20px;
  background-color: #e05624;
  border: 2px solid #ffffff;
  border-radius: 50%;
  z-index: 3;
  box-shadow: 0 0 8px rgba(224, 86, 36, 0.8);
}

/* Nodi/Telefoni reali sul radar */
.node {
  position: absolute;
  width: 8px; height: 8px;
  background-color: #e05624;
  border-radius: 50%;
  box-shadow: 0 0 12px #e05624;
  z-index: 2;
  transform: translate(-50%, -50%);
}

/* Stato FREDDO/DISTANTE (Blu) */
.social-radar.state-cold {
  border-color: rgba(41, 121, 255, 0.3) !important;
}
.social-radar.state-cold::before {
  background: conic-gradient(from 0deg, rgba(41, 121, 255, 0.15) 0deg, transparent 90deg) !important;
}
.social-radar.state-cold .social-core {
  background-color: #2979ff !important;
  box-shadow: 0 0 8px rgba(41, 121, 255, 0.8);
}

/* Connessione status */
.connection-status { text-align: center; margin-bottom: 20px; min-height: 40px; display: flex; align-items: center; justify-content: center; }
.orange-text { color: #e05624; font-weight: 700; }
.blue-text { color: #2979ff; font-weight: 700; }
.main-status-text { display: block; font-size: 0.9rem; font-weight: 500; color: #ffffff; }

.residents-list { margin-bottom: 25px; min-height: 80px; }
.residents-list h3 { font-size: 0.8rem; color: #777777; margin-bottom: 8px; }
.device-count { display: block; font-size: 0.95rem; font-weight: 700; color: #4c8c35; margin-bottom: 8px; }
.residents-list ul { list-style: none; font-size: 0.8rem; line-height: 1.7; }

.social-actions { display: flex; flex-direction: column; gap: 10px; }
.action-btn { padding: 11px; border-radius: 14px; font-size: 0.9rem; font-weight: 600; border: none; }

.active-orange { background-color: #e05624 !important; color: #ffffff !important; }
.active-blue { background-color: #2979ff !important; color: #ffffff !important; }
.btn-disabled { background-color: #222222 !important; border: 1px solid #2d2d2d !important; color: #555555 !important; }

/* ================= STATI COLORI CONSUMI ================= */
.active-green { background-color: #4c8c35 !important; color: #ffffff !important; border: 1px solid #4c8c35 !important; }
.ring-outer.state-buoni {
  background: conic-gradient(from 0deg, #4c8c35 0deg, #4c8c35 90deg, rgba(76, 140, 53, 0.4) 110deg, transparent 120deg, transparent 360deg);
}

.active-yellow { background-color: #e4af3a !important; color: #111111 !important; border: 1px solid #e4af3a !important; }
.ring-outer.state-medi {
  background: conic-gradient(from 0deg, transparent 110deg, rgba(228, 175, 58, 0.4) 120deg, #e4af3a 135deg, #e4af3a 225deg, rgba(228, 175, 58, 0.4) 235deg, transparent 240deg);
}

.active-red { background-color: #b52c24 !important; color: #ffffff !important; border: 1px solid #b52c24 !important; }
.ring-outer.state-pessimi {
  background: conic-gradient(from 0deg, transparent 230deg, rgba(181, 44, 36, 0.4) 240deg, #b52c24 255deg, #b52c24 345deg, rgba(181, 44, 36, 0.4) 355deg, transparent 360deg);
}