:root {
  --navy: #0a1628;
  --navy-dark: #081120;
  --card: rgba(74,179,255,0.07);
  --card-hover: rgba(74,179,255,0.12);
  --cb: rgba(74,179,255,0.18);
  --blue: #4ab3ff;
  --cyan: #00d4ff;
  --white: #e8f0fa;
  --muted: #8fa8c4;
  --dim: #5a7798;
  --green: #1d9e75;
  --amber: #ef9f27;
  --red: #e24b4a;
  --sidebar-w: 220px;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--navy);
  color: var(--white);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy-dark);
  border-right: 1px solid rgba(74,179,255,0.12);
  padding: 20px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display:flex;
  flex-direction:column;
  transition: transform 0.25s ease;
  z-index: 100;
}

.logo {
  display:flex; align-items:center; gap:10px;
  padding: 0 20px 28px;
}
.logo-ring {
  width: 26px; height: 26px; border-radius:50%;
  border: 3px solid var(--blue);
  border-right-color: transparent;
  transform: rotate(-45deg);
}
.logo-text { font-size:15px; font-weight:700; letter-spacing:1.2px; }

.nav-item {
  display:flex; align-items:center; gap:12px;
  padding: 12px 20px;
  cursor:pointer;
  color: var(--muted);
  font-size: 14px;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  user-select: none;
}
.nav-item:hover { background: rgba(74,179,255,0.06); color: var(--white); }
.nav-item.active {
  background: rgba(74,179,255,0.12);
  border-left-color: var(--blue);
  color: #fff;
}
.nav-item.active .icon { color: var(--blue); }
.nav-item .icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; flex-shrink: 0;
}
.nav-item .icon svg { display: block; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
}
.sidebar-footer p { color: var(--dim); font-size:11px; line-height:1.6; }
.sidebar-footer .version { color: var(--dim); opacity: 0.7; }

.mobile-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 200;
  width: 38px; height: 38px;
  background: var(--navy-dark);
  border: 1px solid var(--cb);
  border-radius: 8px;
  color: var(--white);
  cursor: pointer;
  font-size: 18px;
}

/* ===== MAIN ===== */
.main { flex:1; display:flex; flex-direction:column; min-width:0; }

.topbar {
  display:flex; justify-content:space-between; align-items:center;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(74,179,255,0.12);
}
.topbar h1 { font-size:17px; font-weight:600; }
.topbar .sub { color: var(--dim); font-size:12px; margin-top:2px; }
.topbar-right { display:flex; align-items:center; gap:14px; }
.topbar-right .period { color: var(--muted); font-size:13px; }

.refresh-btn {
  background: transparent;
  border: 1px solid var(--cb);
  color: var(--muted);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.refresh-btn:hover { background: var(--card); color: var(--blue); }
.refresh-btn:active { transform: rotate(180deg); }

.avatar {
  width:32px; height:32px; border-radius:50%;
  background: rgba(74,179,255,0.15);
  display:flex; align-items:center; justify-content:center;
  color: var(--blue); font-size:13px; font-weight:600;
}
.content { padding: 24px 28px; flex:1; }

/* ===== CARDS ===== */
.grid { display:grid; gap:16px; }
.grid-3 { grid-template-columns: 1.1fr 1fr 1fr; }
.grid-2 { grid-template-columns: 2fr 1fr; }
.grid-2-eq { grid-template-columns: 1fr 1fr; }
.grid-rel { grid-template-columns: 1.4fr 1fr; }
.mb-16 { margin-bottom: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--cb);
  border-radius: 14px;
  padding: 20px;
}
.card h3 { font-size:14px; font-weight:600; margin-bottom:14px; }
.card.flat-left { padding-left: 17px; }
.stat-num { font-size:32px; font-weight:600; line-height:1; }
.stat-label { color: var(--muted); font-size:13px; margin-top:8px; }

/* Score ring */
.score-ring {
  width:84px; height:84px; border-radius:50%;
  border: 6px solid rgba(29,158,117,0.2);
  position:relative;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.score-ring::before {
  content:''; position:absolute; inset:-6px; border-radius:50%;
  border: 6px solid var(--green);
  border-right-color: transparent;
  border-bottom-color: transparent;
  transform: rotate(45deg);
  transition: transform 0.4s ease;
}
.score-ring.score-warn::before { border-top-color: var(--amber); border-left-color: var(--amber); }
.score-ring.score-danger::before { border-top-color: var(--red); border-left-color: var(--red); }
.score-ring span { font-size:24px; font-weight:600; }

.badge-dot { width:8px; height:8px; border-radius:50%; display:inline-block; }

/* Eventos / lista */
.events-list .event-row {
  display:flex; align-items:center; gap:14px;
  padding:12px 0; border-top:1px solid var(--cb);
}
.events-list .event-row:first-child { border-top:none; padding-top:6px; }
.event-row .meta { flex:1; min-width:0; }
.event-row .meta .name { font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.event-row .meta .desc { color: var(--dim); font-size:11px; margin-top:2px; }
.event-row .device { color: var(--muted); font-size:12px; }
.event-row .time { color: var(--dim); font-size:11px; min-width:50px; text-align:right; }

/* Tabela */
table { width:100%; border-collapse:collapse; }
th { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:0.5px; text-align:left; padding:12px 16px; font-weight:500; }
td { padding:14px 16px; font-size:13px; border-top:1px solid var(--cb); }

/* Botões */
.btn {
  display:flex; align-items:center; justify-content:center; gap:8px;
  padding:14px; border-radius:10px; font-size:13px; cursor:pointer;
  border:1px solid var(--cb); background:var(--card); color:#fff;
  width:100%; transition: all 0.15s;
  font-family: inherit;
}
.btn:hover { background: var(--card-hover); }
.btn:active { transform: scale(0.98); }
.btn-green { background:rgba(29,158,117,0.15); border-color:rgba(29,158,117,0.3); color:#4fd1a5; }
.btn-ghost { background:transparent; color:var(--muted); }
.btn-stack { display:flex; flex-direction:column; gap:10px; }

/* Bar charts (atividade) */
.bar-item { margin-bottom:14px; }
.bar-head { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:5px; }
.bar-name { font-size:13px; color:#fff; }
.bar-detail { color: var(--dim); font-size:10px; margin-top:2px; }
.bar-meta { color: var(--muted); font-size:11px; white-space:nowrap; padding-top:2px; }
.bar-track { height:5px; background:rgba(74,179,255,0.1); border-radius:3px; overflow:hidden; }
.bar-fill { height:100%; background: var(--blue); transition: width 0.4s ease; }
.bar-fill.amber { background: var(--amber); }
.bar-fill.red { background: var(--red); }

.loading { color: var(--muted); padding: 40px; text-align:center; }
.empty { color: var(--muted); padding: 30px; text-align:center; font-size:13px; }

/* Ícones simples (lucide-static usa font) */
.icon { display:inline-block; font-style: normal; }

/* ===== RESPONSIVO ===== */
@media (max-width: 900px) {
  .grid-3, .grid-2, .grid-2-eq, .grid-rel { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: flex; align-items: center; justify-content: center; }
  .topbar { padding: 14px 16px 14px 60px; }
  .content { padding: 18px 16px; }
  .topbar h1 { font-size: 15px; }
}
