:root {
  --navy: #11161D;
  --navy-light: #1A222D;
  --blue: #2F7DE1;
  --green: #2E7D32;
  --red: #C62828;
  --orange: #EF6C00;
  --gray: #6B7280;
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --text: #1C1C1E;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

/* Sidebar */
.sidebar {
  width: 230px;
  background: var(--navy);
  color: #C9D2DE;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 24px;
  font-weight: 700;
  font-size: 17px;
  color: white;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(47,125,225,0.2);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: #9AA7B8;
  font-size: 14px;
  text-align: left;
  padding: 11px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--navy-light); color: white; }
.nav-item.active { background: var(--blue); color: white; }
.nav-icon { font-size: 14px; opacity: 0.9; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 22px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  animation: pulse 1.4s infinite;
}
.conn-dot.offline { background: var(--red); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.version { font-size: 11px; color: #5C6878; margin-top: 6px; }

/* Main */
.main {
  flex: 1;
  padding: 28px 36px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1 { font-size: 24px; font-weight: 700; margin: 0; }
.clock { font-size: 13px; color: var(--gray); }

.panel { display: none; }
.panel.active { display: block; }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-left: 4px solid var(--gray);
}
.stat-card.accent-green { border-left-color: var(--green); }
.stat-card.accent-orange { border-left-color: var(--orange); }
.stat-card.accent-blue { border-left-color: var(--blue); }

.stat-value { font-size: 30px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--gray); margin-top: 4px; }

/* Cards / tables */
.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header-sub { font-weight: 400; color: var(--gray); font-size: 13px; }

.filters { justify-content: space-between; }
.filter-controls { display: flex; gap: 8px; }
.filter-controls select {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  padding: 10px 20px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover { background: #FAFBFD; }
.table tbody tr:last-child td { border-bottom: none; }

.empty-state {
  text-align: center;
  color: var(--gray);
  padding: 40px 0;
  font-size: 14px;
}

.table-footer {
  padding: 14px 20px;
  display: flex;
  justify-content: center;
}

.btn-secondary {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}
.btn-secondary:hover { background: #ECEFF3; }

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; }

.pill-online { background: #E5F3E7; color: var(--green); }
.pill-online .pill-dot { background: var(--green); }
.pill-offline { background: #F1F2F4; color: var(--gray); }
.pill-offline .pill-dot { background: var(--gray); }

.pill-active { background: #E3F0FC; color: var(--blue); }
.pill-inactive { background: #F1F2F4; color: var(--gray); }

.badge-reason {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #FCE8E8;
  color: var(--red);
}
.badge-reason.manuel { background: #FDEBD3; color: var(--orange); }

.map-link { color: var(--blue); text-decoration: none; font-size: 13px; }
.muted { color: var(--gray); }

.battery-low { color: var(--red); font-weight: 700; }

/* Recent activity list (overview) */
.recent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.recent-row:last-child { border-bottom: none; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 80px; }
  .brand-name, .nav-item span:last-child, .version, #conn-text { display: none; }
  .main { padding: 20px; }
}
