/* (Use the styles.css content you provided earlier) */
/* Paste your styles.css content here. For brevity, here's the same content you gave before. */

:root{
  /* Initial Dark Theme + menu tweaks + relay indicator colors */
  --bg: linear-gradient(180deg,#071014 0%, #0b1b1e 60%, #071014 100%);
  --card: rgba(8,18,20,0.88);
  --muted: #9bb6b3;
  --muted-strong: #e6f7f4;
  --accent: #2dd4bf;
  --accent-2: #34d399;
  --temp-accent: #ff9e6b;
  --pressure-accent: #60a5fa;
  --danger: #ff7b7b;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0,0,0,0.6);
  --border-light: rgba(255,255,255,0.05);

  --menu-bg: rgba(255,255,255,0.03);
  --menu-item-color: #d9efe9;
  --menu-item-hover-bg: rgba(52,163,115,0.08);
  --menu-font-size: 15px;
  --menu-font-weight: 600;

  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: var(--muted-strong);
  color-scheme: dark;
}

/* reset */
*{box-sizing:border-box}
html,body{height:100%;margin:0;background:var(--bg);-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}

/* Topbar */
.topbar{
  display:flex;justify-content:space-between;align-items:center;padding:14px 22px;
  border-bottom:1px solid rgba(255,255,255,0.03);background:transparent;
}
.menu-btn{
  background:var(--card);border-radius:10px;border:none;padding:8px 10px;box-shadow:var(--shadow);cursor:pointer;font-size:16px;color:var(--muted)
  -webkit-appearance:none;
}
.brand{display:flex;align-items:center;gap:14px}
.logo{width:42px;height:42px;filter:brightness(1.1) saturate(0.9)}
.brand-text .app-title{
  font-weight:800;
  font-size:20px;
  line-height:1;
  color:var(--accent-2);
}
.app-sub{font-size:13px;color:var(--muted);margin-top:2px;opacity:0.95}
.top-timestamp{color:var(--muted);font-size:13px;margin-right:12px}
.profile-btn{background:var(--card);border-radius:10px;border:none;padding:8px 10px;box-shadow:var(--shadow);cursor:pointer;color:var(--muted)}

/* Menu dropdown */
.menu-dropdown{
  position:absolute;
  left:12px;
  top:54px;
  min-width:180px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
  border-radius:12px;
  box-shadow:0 20px 40px rgba(2,8,6,0.55);
  border:1px solid rgba(255,255,255,0.06);
  display:none;
  flex-direction:column;
  padding:6px;
  z-index:1200;
  backdrop-filter: blur(6px);
}
.menu-dropdown.show{ display:flex; }
.menu-item{
  background:transparent;
  color:var(--menu-item-color);
  border:none;
  padding:10px 14px;
  text-align:left;
  border-radius:10px;
  cursor:pointer;
  font-size:var(--menu-font-size);
  font-weight:var(--menu-font-weight);
  transition: background 120ms ease, color 120ms ease, transform 80ms ease;
  letter-spacing:0.1px;
}
.menu-item + .menu-item{ margin-top:4px; }
.menu-item:hover{
  background:var(--menu-item-hover-bg);
  color:var(--accent-2);
  transform: translateY(-1px);
}
.menu-item:focus{ outline:2px solid rgba(45,212,191,0.14); outline-offset:2px; }

/* layout & cards */
.layout{ max-width:1200px;margin:20px auto;display:grid;grid-template-columns:360px 1fr;gap:20px;padding:6px;grid-auto-rows: auto 1fr; }
.col{display:flex;flex-direction:column;gap:16px}
.card{background:var(--card);border-radius:var(--radius);box-shadow:var(--shadow);padding:16px;border:1px solid var(--border-light);color:var(--muted);}
.card-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
.label{font-weight:700;color:var(--accent-2)}
.muted{color:var(--muted)}
.small{font-size:13px}
.top-widgets{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.widget.large{display:flex;flex-direction:column;justify-content:space-between;min-height:140px}
.widget-heading{display:flex;justify-content:space-between;align-items:center}
.widget-value{font-size:36px;font-weight:800;margin-top:6px;color:var(--accent)}
.unit{color:var(--muted)}
.gases{display:flex;gap:8px;margin-top:8px}
.gas{flex:1;padding:12px;border-radius:10px;background:linear-gradient(180deg, rgba(47,157,243,0.02), rgba(47,157,243,0.005));text-align:center;color:var(--muted)}
.gas-label{color:var(--muted);font-size:13px}
.gas-value{font-weight:700;font-size:18px;margin-top:6px;color:var(--accent-2)}
.left-col .map-card{display:flex;flex-direction:column;height:100%}
.map-frame{border-radius:10px;overflow:hidden;margin-top:8px;flex:1 1 auto}
.map{height:100%;width:100%;min-height:220px}
.chart-card{display:flex;flex-direction:column;gap:8px;min-height:200px}
.chart-resizer{height:8px;background:linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.035));border-radius:6px;cursor:ns-resize;margin-bottom:4px}
.chart-wrap{width:100%;height:320px;overflow:hidden;border-radius:10px;background:linear-gradient(180deg, rgba(8,16,16,0.6), rgba(12,24,24,0.6))}
#historyChart{width:100% !important;height:100% !important;display:block}
.bottom-area{display:flex;gap:16px;align-items:stretch}
.anomaly-card, .device-card{flex:1;min-width:260px;min-height:220px;display:flex;flex-direction:column;justify-content:flex-start;padding:16px;border-radius:12px;background:var(--card);box-shadow:var(--shadow);border:1px solid var(--border-light);color:var(--muted);}
.device-head{display:flex;justify-content:space-between;align-items:center}
.status-pill{padding:8px 12px;border-radius:999px;color:#071014;font-weight:700;display:inline-flex;align-items:center;gap:8px}
.status-pill .dot{width:10px;height:10px;border-radius:50%;display:inline-block;box-shadow:0 0 6px rgba(0,0,0,0.12)}
.status-pill.online{background:var(--accent-2)}
.status-pill.online .dot{background:#16a34a; box-shadow:0 2px 8px rgba(22,163,74,0.12)}
.status-pill.offline{background:var(--danger)}
.status-pill.offline .dot{background:#ff6b6b; box-shadow:0 2px 8px rgba(255,107,107,0.12)}
.device-body{margin-top:6px}
.device-body #device-last-seen{font-weight:700;margin-top:6px}
.status-pill.anomaly-normal{background:var(--accent-2)}
.status-pill.anomaly-abnormal{background:var(--danger)}
.anomaly-body{margin-top:10px;background:linear-gradient(180deg, rgba(20,40,36,0.18), transparent);padding:10px;border-radius:10px;flex:1 1 auto}
.legend-item{display:inline-flex;align-items:center;gap:8px;color:var(--muted)}
.sw{width:12px;height:10px;border-radius:3px;display:inline-block}
.sw.temp{background:linear-gradient(90deg,var(--temp-accent), #ffb089)}
.sw.pres{background:linear-gradient(90deg,var(--pressure-accent), #7fd1ff)}
:root{--chart-temp: var(--temp-accent); --chart-pres: var(--pressure-accent);}

/* Relay indicator styles */
.relay-indicator{
  width:44px;height:44px;border-radius:50%;border:none;display:inline-flex;align-items:center;justify-content:center;
  background:rgba(255,255,255,0.03); color:var(--muted-strong); cursor:default; transition:transform 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.relay-indicator .relay-label{font-weight:700}
.relay-indicator.relay-on{ background: linear-gradient(180deg,#b9ffd6,#34d399); color:#071014; cursor:pointer; transform:translateY(0); box-shadow:0 10px 22px rgba(50,200,140,0.18);}
.relay-indicator.relay-off{ background: linear-gradient(180deg,#ffd6d6,#ff7b7b); color:#071014; cursor:default;}
.relay-indicator.relay-unknown{ background: linear-gradient(180deg,#fff7d6,#ffcc3b); color:#071014; cursor:not-allowed; }
.relay-indicator[disabled]{ opacity:0.6; cursor:not-allowed; transform:none; }

/* Modal (config) styling */
.modal-overlay{ position:fixed; inset:0; display:none; align-items:center; justify-content:center; background:rgba(2,6,6,0.45); z-index:1300; }
.modal-overlay.show{ display:flex; }
.modal{ background:var(--card); border-radius:12px; padding:18px; width:480px; max-width:94%; box-shadow:0 20px 50px rgba(0,0,0,0.6); border:1px solid var(--border-light); color:var(--muted); }
.modal h3{ margin:0 0 12px 0; color:var(--accent-2) }
.config-form .field{ margin-bottom:12px }
.config-form label{ display:block; margin-bottom:6px; font-size:13px; color:var(--muted) }
.config-form input[type="range"]{ width:100% }
.config-form input[type="text"], .config-form input[type="password"], .config-form select{
  width:100%; padding:8px 10px; border-radius:8px; border:1px solid rgba(255,255,255,0.04); background:rgba(255,255,255,0.02); color:var(--muted); outline:none;
}
.checkbox-field{ display:flex; align-items:center; gap:8px }
.checkbox-field input[type="checkbox"]{ width:16px; height:16px }
.modal-actions{ display:flex; justify-content:flex-end; gap:8px; margin-top:10px }
.btn{ padding:8px 12px; border-radius:8px; border:none; cursor:pointer }
.btn-ghost{ background:transparent; color:var(--muted); border:1px solid rgba(255,255,255,0.03) }
.btn-primary{ background:var(--accent-2); color:#071014; font-weight:700 }

/* responsive */
@media (max-width:480px){ .modal{ width:94% } }

/* safety */
canvas{display:block;max-width:100%}
.map-coords,.muted{color:var(--muted);font-size:13px}