* { box-sizing: border-box; }
body {
  font-family: Segoe UI, system-ui, sans-serif;
  margin: 0;
  background: #f5f7fa;
  color: #333;
}
.header {
  background: #009fe3;
  color: #fff;
  padding: 16px 24px;
}
.header h1 { margin: 0 0 4px; font-size: 1.35rem; }
.subtitle { margin: 0 0 12px; opacity: .9; font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #fff;
  color: #009fe3;
  font-weight: 600;
  cursor: pointer;
}
.muted { font-size: .85rem; opacity: .85; }
.kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 24px;
}
.kpi {
  background: #fff;
  border-radius: 10px;
  padding: 16px 24px;
  min-width: 120px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.kpi-val { display: block; font-size: 1.75rem; font-weight: 700; color: #009fe3; }
.kpi-label { font-size: .8rem; color: #666; }
.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 24px 32px;
  align-items: flex-start;
}
.table-wrap { flex: 1; min-width: 320px; overflow-x: auto; }
.hint { font-size: .85rem; color: #666; margin: 0 0 8px; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eee; font-size: .9rem; }
th { background: #e8f6fc; color: #006fa0; }
#devicesTable tbody tr { cursor: pointer; }
#devicesTable tbody tr:hover { background: #f0f9fd; }
#devicesTable tbody tr.selected { background: #d4eef9; }
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot.online { background: #2ecc71; }
.dot.offline { background: #95a5a6; }
.detail-panel {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
  padding: 16px;
  margin-top: 0;
}
@media (min-width: 1100px) {
  .layout { flex-wrap: nowrap; }
  .detail-panel { margin-left: 16px; position: sticky; top: 12px; max-height: calc(100vh - 40px); overflow: hidden; display: flex; flex-direction: column; }
  .detail-panel:not(.hidden) { display: flex; }
  .events-wrap { overflow-y: auto; flex: 1; }
}
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.detail-header h2 { margin: 0; font-size: 1.1rem; color: #009fe3; }
.btn-link {
  border: none;
  background: none;
  color: #009fe3;
  cursor: pointer;
  font-size: .85rem;
}
.detail-meta { font-size: .85rem; color: #666; margin: 8px 0 12px; line-height: 1.4; }
.detail-sub { margin: 16px 0 8px; font-size: .95rem; color: #006fa0; }
.nvv-pending-box {
  margin-bottom: 12px;
  font-size: .85rem;
}
.nvv-pending-box .nvv-table { margin-top: 6px; }
.events-table { font-size: .82rem; }
.events-table th { background: #f5f7fa; }
.event-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.event-type.login_ok { background: #d5f5e3; color: #1e8449; }
.event-type.sync_ok { background: #d6eaf8; color: #1a5276; }
.event-type.sync_fail { background: #fdebd0; color: #b7950b; }
.event-type.pedido_enviado { background: #e8daef; color: #6c3483; }
.event-type.app_error { background: #fadbd8; color: #922b21; }
.event-type.api_error { background: #f5b7b1; color: #78281f; }
.error {
  margin: 12px 24px;
  padding: 12px;
  background: #fdecea;
  color: #c0392b;
  border-radius: 8px;
}
.detail-panel .error { margin: 8px 0; }
.hidden { display: none !important; }
