:root {
  --bg: #0b1220;
  --bg-2: #0f172a;
  --panel: #111b33;
  --panel-2: #0f1a2f;
  --stroke: #1c2a4a;
  --text: #e6edf7;
  --muted: #9bb0d3;
  --brand: #00c2a8;
  --brand-2: #3dd2ff;
  --warning: #ffb020;
  --danger: #ff6b6b;
  --success: #2dd4bf;
  --shadow: 0 10px 30px rgba(2, 8, 23, 0.5);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(61, 210, 255, 0.15), transparent 55%),
    radial-gradient(800px 500px at 100% 10%, rgba(0, 194, 168, 0.2), transparent 60%),
    var(--bg);
  color: var(--text);
}

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

img {
  max-width: 100%;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0d1830 0%, #0a1224 100%);
  border-right: 1px solid var(--stroke);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 28px;
}

.brand .logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  display: grid;
  place-items: center;
  color: #00131e;
  font-weight: 700;
}

.login .brand .logo {
  width: auto;
  height: auto;
  border-radius: 16px;
  background: transparent;
  object-fit: contain;
  display: inline-flex;
}

.login .brand .logo-text {
  width: auto;
  height: auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(140deg, rgba(0, 194, 168, 0.22), rgba(61, 210, 255, 0.26));
  border: 1px solid rgba(61, 210, 255, 0.45);
  box-shadow: 0 10px 20px rgba(2, 8, 23, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  text-transform: none;
}

.login .brand .logo-text .logo-mark {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--brand-2);
}

.login .brand .logo-text .logo-word {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.4px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  justify-content: center;
  opacity: 0.85;
}

.sidebar-footer img {
  width: 120px;
  height: auto;
  object-fit: contain;
}

.nav a {
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.nav a .nav-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav a .icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav a .icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.nav a.active,
.nav a:hover {
  background: rgba(0, 194, 168, 0.12);
  color: var(--text);
  border-color: rgba(0, 194, 168, 0.4);
}

.nav span.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(61, 210, 255, 0.15);
  color: var(--brand-2);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 18px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(10, 16, 32, 0.6);
  backdrop-filter: blur(6px);
}

.topbar .title {
  font-size: 22px;
  font-weight: 600;
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.topbar-brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px;
}

.topbar .actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.only-mobile {
  display: none;
}

.only-desktop {
  display: inline-flex;
}

.button {
  border: none;
  background: linear-gradient(130deg, var(--brand), var(--brand-2));
  color: #001219;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--stroke);
}

.button.secondary.active {
  border-color: rgba(0, 194, 168, 0.5);
  color: var(--text);
  background: rgba(0, 194, 168, 0.12);
}

.page {
  padding: 28px 32px 40px;
  display: grid;
  gap: 22px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.cards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid.cards.single-column {
  grid-template-columns: 1fr;
}

.card {
  background: linear-gradient(160deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}

.card p {
  margin: 0;
  color: var(--muted);
}

.stat {
  font-size: 28px;
  font-weight: 600;
}

.panel {
  background: rgba(14, 22, 40, 0.7);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.panel-header h2 {
  font-size: 18px;
  margin: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(28, 42, 74, 0.6);
  font-size: 14px;
}

.table tr.row-link {
  cursor: pointer;
}

.table tr.row-link:hover {
  background: rgba(0, 194, 168, 0.08);
}

.table tr.alarm-above {
  background: rgba(255, 107, 107, 0.08);
}

.table tr.alarm-above:hover {
  background: rgba(255, 107, 107, 0.14);
}

.table tr.alarm-below {
  background: rgba(255, 176, 32, 0.08);
}

.table tr.alarm-below:hover {
  background: rgba(255, 176, 32, 0.14);
}

.table th {
  color: var(--muted);
  font-weight: 500;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.status.offline::before {
  background: var(--danger);
}

.status.warning::before {
  background: var(--warning);
}

.status.danger {
  color: var(--danger);
}

.status.danger::before {
  background: var(--danger);
}

.search {
  background: #0b162d;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  min-width: 240px;
}

.split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}

.chart {
  height: 220px;
  background: rgba(10, 18, 36, 0.5);
  border: 1px solid rgba(61, 210, 255, 0.2);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}

.chart::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 16, 32, 0.2), transparent 60%);
  pointer-events: none;
}

.chart canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(13, 20, 38, 0.9);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field input {
  background: #0b162d;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
}

.field select {
  background: #0b162d;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
}

.helper {
  color: var(--muted);
  font-size: 13px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 194, 168, 0.2);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(13, 23, 42, 0.7);
  display: flex;
  justify-content: space-between;
}

.map {
  height: 280px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--stroke);
}

.leaflet-container {
  font: inherit;
}

.leaflet-control-attribution {
  background: rgba(10, 16, 32, 0.7) !important;
  color: var(--muted) !important;
  border-radius: 6px;
  padding: 2px 6px;
}

.leaflet-control-zoom a {
  background: #0b162d !important;
  color: var(--text) !important;
  border: 1px solid var(--stroke) !important;
}

.marker-label {
  background: rgba(0, 194, 168, 0.9);
  color: #00131e;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.marker-label .marker-link {
  color: #00131e;
  text-decoration: none;
}

.marker-label .marker-link:hover {
  text-decoration: underline;
}

.wemo-marker {
  width: 20px;
  height: 20px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  transform: rotate(-45deg);
  position: relative;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.wemo-marker::after {
  content: "";
  width: 8px;
  height: 8px;
  background: #0b1220;
  border-radius: 50%;
  position: absolute;
  top: 5px;
  left: 5px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    padding: 18px 20px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .topbar .actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .search {
    min-width: 0;
    flex: 1 1 100%;
  }

  .only-mobile {
    display: inline-flex;
  }

  .only-desktop {
    display: none;
  }

  .page {
    padding: 20px;
  }

  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .timeline-item {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .table {
    min-width: 640px;
  }
}
